View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.sdk,microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default launching Excel with a macro to operate on CSV data?

I'd do this in VBS:

Dim xlApp
Dim xlAddin
Dim xlWks

Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlAddin = xlApp.workbooks.Open("C:\youraddinnamehere.xla")

Set xlWks = xlApp.workbooks.Open("C:\yourcvsfilenamehere.csv") .worksheets(1)

xlApp.Run "'" & xlAddin.Name & "'!yourmacronamehere"

'and if you want to close things...
'xlWks.Parent.Close False 'cancel changes to .csv file
'xlAddin.Close False 'cancel changes to addin
'xlApp.Quit
'
'Set xlWks = Nothing
'Set xlAddin = Nothing
'Set xlApp = Nothing

======
ps. I'm assuming that a macro template is an addin.


Rob Y wrote:

Well, I found some sample code that shows me how to do OLE automation of
Excel. The funny thing is that I can't for the life of me find any
documentation on what API's Excel offers for OLE automation. Even the
guy who wrote the sample code said that he figured out what calls to
make by recording macros and guessing based on the macro listings.

Is that weird or what? Maybe I'm just looking in the wrong places. Or
maybe there's a standard way to map from XLL API's (well documented) to
OLE-callable stuff.

Does anybody know where to find documentation and/or code samples?

Again, specifically, I want to

1. Launch Excel.
2. Load up a macro template.
3. Load up a csv data file.
4. run a macro in the template.

Sounds pretty straightforward, no?

Thanks,
Rob


--

Dave Peterson