Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Excel Application

Status
Not open for further replies.

NatashaM

Programmer
Apr 29, 2002
9
US
I use the code
Set X = CreateObject("Excel.Application")
X.Visible = True
X.Workbooks.Open (Xfile)

that works with MS Office 2000 and
gives an error with MS Office XP "Open method of Workbooks class failed".

Any suggestions ?
Thanks
 
Hi there,
I have office XP installed and your code works fine, to be exact i used this:

Set X = CreateObject("Excel.Application")
X.Visible = True
X.Workbooks.Open (App.Path & "\test.xls")

What library are you using in your project references? the reference to add should be

Microsoft Excel 10.0 Object Library

This should point to your excel executable and everything should be fine.

If not pls reply and i'll have a look again.
'mi casa es su casa'
]-=tty0=-[
ICQ:82621399
 
I realized the problem is in different. First I try to export the Crystal report to MSExcel. And the problem is here - in the exported file. When I try to open that exported report in Excel I get an error "Errors were detected in 'FileName.xls', but MSExcel was able to open the file by making the repairs listed below." So that the reason why it doesn't work in code. But I don't have such a problem with Office 2000, only with XP.

My code is

CrystalReport1.PrintFileType = crptExcel50
Xfile = Left(CrystalReport1.ReportFileName, Len(CrystalReport1.ReportFileName) - 3) + "xls"

If FileExist(Xfile) = True Then
Kill (Xfile)
End If
CrystalReport1.PrintFileName = Xfile
CrystalReport1.Action = 1

Set X = CreateObject("Excel.Application")
X.Visible = True
X.Workbooks.Open (Xfile)


Thanks a lot.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top