|
-
Feb 2nd, 2004, 12:10 AM
#1
Thread Starter
New Member
Calling Excel Macro's from VB .exe
Hi, I have a simple .exe that opens an Excel sheet, runs a macro and closes:
<code>
Sub Main()
'Opens Excel, runs a macro and closes
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Application.DisplayAlerts = False
Dim wb As Excel.Workbook
Set wb = xlApp.Workbooks.Open("C:\book.xls")
'wb = Excel.Workbook.Open("C:\book.xls")
' Make it invisible:
xlApp.Visible = False
' Run the macro:
xlApp.Run ("formatWattle")
xlApp.Quit
Set xlApp = Nothing
Set wb = Nothing
End Sub
</code>
When I run the macro from within Excel, it executes in about 2 seconds, start to finish. When I call the macro from an .executable, it takes a few minutes, and sometimes just plain crashes on me.
The .exe is compiled with VB5, since I tried with VB.net and it was just as slow.
If anyone can tell me how to get better results with what I am doing, please fill me in, as it is difficult to find information on something like this.
Many thanks,
.tehwa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|