Excel : opening existing xls-file

Excel : opening existing xls-file

Postby Demont.frank » Tue Apr 14, 2009 12:35 pm

Hello,

Till now i can use a excel aplication as :

oExcel := CreateObject( "Excel.Application" )
oWorkBook := oExcel:WorkBooks:Add()
........

Ok , this works , excel seems to generate a file (name) , map1.xls , ....


Now , i try to open a existing xls file without succes , i have

oExcel := CreateObject( "Excel.Application" )
oWorkBook := oExcel:WorkBooks:Add()

cDest := "TESTDIR\ExcelFile.xls"
oExcel:WorkBooks:Open(cDest)

This give a error :

Error description: Error Excel.Application:WORKBOOKS/14 DISP_E_BADPARAMCOUNT: OPEN
Args:
[ 1] = C TESTDIR\ExcelFile.xls

Tryed also to open before workbooks:add

What do i wrong , who can give an example to open an existing xls-file ?

Frank
Demont.frank
 
Posts: 5
Joined: Fri Sep 07, 2007 2:47 pm

Re: Excel : opening existing xls-file

Postby Loach » Tue Apr 14, 2009 1:06 pm

local i, hActiveWorkbook,ppp:=CurDrive()+':\'+GetCurDir()+'\'
if !file(ppp+"prom.xls")
return .f.
endif
oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Open(ppp+"prom.xls")
oExcel:Visible := .T.
oHoja1 := oExcel:Get( "ActiveSheet" )
...

This code work fine for me.
Best regards!
Sergey (Loach) Abelev
fwh 9.04/xHarbour 1.2.1 (Rev. 6406)/Bcc55
Loach
 
Posts: 41
Joined: Thu Dec 22, 2005 7:39 am
Location: Gomel, Belarus

Re: Excel : opening existing xls-file

Postby Demont.frank » Tue Apr 14, 2009 2:36 pm

It seems that workbook:open(cFile) can not be used with relative directory's

Will not work :

workbook:open("Test\cFile") , Test is supposed to be a subdirectory from the work directory

Frank
Demont.frank
 
Posts: 5
Joined: Fri Sep 07, 2007 2:47 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests