Hi yzhang,
There is nothing wrong with your Office, I presume.
Try following code to prove it:
Dim ExcelApp As Object
Dim sFileName As String
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
sFileName = ExcelApp.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFileName <> "False" Then
ExcelApp.Workbooks.Open FileName:=sFileName
MsgBox "File " & sFileName & " is opened in Excel!" & vbCrLf & _
"Pressing OK Button will close it and Excel Application"
ExcelApp.ActiveWorkbook.Close
Else
MsgBox "Cancel button was selected!"
End If
ExcelApp.Quit
This code will open and close new instance of Excel every time you run
it.
You can open any workbook from the dialog.
To run some code from the opened *.xls workbook you should place it NOT
in Auto_Open() procedure, but in Sub Workbook_Open() event procedure
you create in ThisWorkbook code module.
Hope this will help you.
With respect
Alex
Quote:
> I have the following problem with microsoft Visual studio or Office
2000
> I write the following program in visual basic 6.0, try to auto run a
> macro which resides in excel 2000. However,
> it runs OK when excel 2000 is Open. When excel is closed, it will give
> an error: Run-Time Error '429': ActiveX
> component can't create object.
> I try to uninstall or reinstall office 2000, it does not solve the
> problem. I suspect something is missing in my
> windows 2000(However, I just resintall windows 2000 and everything
seems
> fine), or something is wrong with the
> activeX server. Could anyone have any idea what is wrong with that?
> Thanks in advance.
> Sub main()
> Dim myXL As Object
> Dim sht
> Set sht = CreateObject("Excel.Sheet")
> Set sht = GetObject("R:\website\w3website\arb20\chart.xls")
> sht.Application.Visible = True
> sht.Parent.Windows(1).Visible = True
> sht.Application.Run "arb20graph"
> 'Set myXL = GetObject("R:\website\w3website\arb20\chart.xls")
> 'myXL.Application.Visible = True
> 'myXL.Parent.Windows(1).Visible = True
> 'myXL.Application.run "arb20graph"
> End Sub
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Sent via Deja.com http://www.deja.com/
Before you buy.