VB.net and Excel COM exe

T

tehwa

I have a cunning plan to open an Excel workbook and call a macro insid
that will open, then manipulate another .xls file on the hard driv
before saving it in a different location.

The .xls file is opened with a .exe file, which opens the workbook an
calls the macro in the background.

For clarity, the file is called 'macroOfDeathFile.xls', with the macr
being called 'macroOfDeath':

<VB CODE>

Module fquicken
Sub Main()
Dim xlApp As Excel.Application
xlApp = CreateObject("Excel.Application")
xlApp.Application.DisplayAlerts = False
Dim wb As Excel.Workbook
wb = xlApp.Workbooks.Open("C:\macroOfDeathFile.xls")
xlApp.Visible = True
xlApp.Run("macroOfDeath")
xlApp.Quit()
xlApp = Nothing
wb = Nothing
End Sub
End Module

</VBCODE>

This will execute, but I do not want Excel to be visible. Some woul
say "change xlApp.Visible to false":

but if it is set to true, it executes the macro and saves a file in
seconds, while if it is set to 'xlApp.Visible = false' then it take
about 1 minute.

I am hoping that someone amongst this community works in VB and Exce
who can tell me what Microsoft are playing at here, and perhaps sugges
a possible workaround.

Cheers,

.tehw
 
J

Juan Pablo González

*Try* setting

xlApp.ScreenUpdating = False

before running the macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top