Hi again Bill,
Yes it is a
VB application, not VBA within Excel.
My problem all started with trying to open an Excel file. See "Open an Excel
File" on Jan 8/05 at microsoft.public.
vb.syntax.
Following Jezebel's suggestion, I removed the reference to the Excel
library, and the following Form_Load event coding worked:
Private Sub Form_Load()
Dim xlApp As Object
Dim xlBook as Object
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Program Files\FileA.xls")
xlApp.Visible = True
xlApp.ShowWindowsInTaskbar = True
End Sub
(Note: Just before End Sub, if I add: xlApp.WindowState = xlMinimized
I get a run-time error 1004: Unable to set WindowState property of the
Application class.)
I thought my problems were solved, until I tried the following command
button event:
Private Sub cmdOK_Click()
Dim xlApp As Object
Dim xlBook as Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Windows("FileA.xls").Activate
....
End Sub
The last statement before End Sub causes Run-time error 9: Subscript out of
range.
Bill, I would appreciate your further comments.
Regards,
Bob Mignault
"Bill Manville" wrote in message
...
I guess this is a VB application, not VBA within Excel?
I assume you have referenced the Excel object library
After Windows("FileA.xls").Activate
I assume you mean xlApp.Windows("FileA.xls").Activate
and xlApp.ActiveWorkbook.Save
Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup