Hello,
Maybe a strange question but I'm looking in FWH for a way to import an excel-file into a Word-document.
Anyone any idea?
Thanks a lot in advance.
FWH, ole, Word and Excel
FWH, ole, Word and Excel
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: FWH, ole, Word and Excel
Michel,
Do you mean to embed the spreadsheet into the Word doc, or to export its data into Word ? thanks
Do you mean to embed the spreadsheet into the Word doc, or to export its data into Word ? thanks
Re: FWH, ole, Word and Excel
Antonio,
I indeed want to embed the spreadsheet into the Word doc.
Thanks.
I indeed want to embed the spreadsheet into the Word doc.
Thanks.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Re: FWH, ole, Word and Excel
Michel,
I use a lot of copy and paste with excel. You may want to try to adapt the code
I do not know if it can be done but you could try something like oPage:paste(). I do not know why but sometime the formating is lost or partialy lost during the operation.
I use a lot of copy and paste with excel. You may want to try to adapt the code
Code: Select all
oExcel := CREATEOBJECT( "Excel.Application" )
oExcel:WorkBooks:Open( "C:\Where_is_the_file\Name_of_the_file" )
nI := which sheet I want to use (1st, 2nd, 3rd ...)
oSheet := oExcel:Sheets( nI )
oTemp := oSheet:Range( the range U want to copy ) //Range( "A1","AL37" )
oTemp:copy()
// I open a new excel file select a sheet then paste
oSheet2:paste()
Regards,
André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
André Dutheil
FWH 13.04 HB 3.2 BCC 5.82 MinGW 4.5.2 MSVS 10
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: FWH, ole, Word and Excel
There are other ways, but this is oneway.
Keeps a link to excel table and any changes in excel are ready by word.
Retains excel formatting.
Code: Select all
function Main()
local oWord, oExcelRange, oDoc
oWord := WinWordObj()
if oWord == nil
MsgStop( "Can not open Word Application" )
return nil
endif
oExcelRange := GetExcelRange( "c:\fwh\samples\compare.xls", "Regions", "Sales" )
if oExcelRange == nil
MsgStop( "Can not read Excel Range" )
return nil
endif
oDoc := oWord:Documents:Add()
oExcelRange:Copy()
oDoc:Paragraphs( oDoc:Paragraphs:Count ):Range:InsertParagraphAfter()
oDoc:Paragraphs( oDoc:Paragraphs:Count ):Range:PasteExcelTable( .t., .f., .t. )
oWord:Visible := .t.
return nil
Retains excel formatting.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India