|
|
Question : Problem: Run Excel Macro from Visual Basic 6.0
|
|
I am trying to develop a vb app to update web queries in Excel. I have macros created in Excel, but would like to run them from the vb app. Thus far I have been unable to find any code to do this. Can someone shed some light on this... My goal is to have this take place in the background w/o having to open/view the spreadsheet itself. I hope this all make sense as I am a novice in the programming business. I appreciate any help.
Thank You.
|
Answer : Problem: Run Excel Macro from Visual Basic 6.0
|
|
What about this (also will be appreciated if moderator move this to vb section!!!!!:-)
If appExcel Is Nothing Then 'There is no running excel
session Set appExcel = CreateObject("Excel.Application") 'Start a new session End If
MyPath = App.Path MyPath = MyPath & "\SomeSheet.xls"
Workbooks.Open FileName:=MyPath ' Application.Run "'SomeSheet.xls'!Auto_Open" Application.Run "'SomeSheet.xls'!SomeMacro" ActiveWorkbook.Save ActiveWorkbook.Close
appExcel.Quit Set appExcel = Nothing
|
|
|