So Lynn, are you done with C# or just spreading your wings?
An alternative would be to have a module named (say) "m_OpenClose" in your xlsm
that has:
Sub Auto_Open()
'Startup code here executes when the workbook is opened
Call testmacro
ThisWorkbook.Save
Application.Quit
End Sub 'Auto_Open
Sub Auto_Close()
'Cleanup code here
End Sub
In your C++ app:
PS C:\Users\lmc $E = New-Object -ComObject Excel.Application
PS C:\Users\lmc $workbook = $E.Workbooks.Open("C:\dii\spreadsheet2.xlsm")
PS C:\Users\lmc $workbook.RunAutoMacros 1
This enables your xlsm to do all the work just by opening it; - runs your
macro, saves itself, shuts down Excel.
Note: If you put the code in the Workbook_Open event in the ThisWorkbook
component you can skip the 3rd line of code in C++ app.
Optionally, your "testmacro" can save and quit as well so all you need to do is
run it.
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion