FWH, ole, Word and Excel

FWH, ole, Word and Excel

Postby driessen » Fri Oct 11, 2013 2:17 pm

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.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: FWH, ole, Word and Excel

Postby Antonio Linares » Fri Oct 11, 2013 2:52 pm

Michel,

Do you mean to embed the spreadsheet into the Word doc, or to export its data into Word ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH, ole, Word and Excel

Postby driessen » Sat Oct 12, 2013 1:52 pm

Antonio,

I indeed want to embed the spreadsheet into the Word doc.

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: FWH, ole, Word and Excel

Postby ADutheil » Sat Oct 12, 2013 5:09 pm

Michel,

I use a lot of copy and paste with excel. You may want to try to adapt the code
Code: Select all  Expand view

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()
 


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.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: FWH, ole, Word and Excel

Postby nageswaragunupudi » Sun Oct 13, 2013 5:33 am

There are other ways, but this is oneway.
Code: Select all  Expand view
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
 

Keeps a link to excel table and any changes in excel are ready by word.
Retains excel formatting.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests