View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
KM[_2_] KM[_2_] is offline
external usenet poster
 
Posts: 24
Default running a macro saved as a string

Try

Eval(xlApp.PublicSub)

-----Original Message-----
I have an Access app that manipulates a spreadsheet. The

spreadsheet
can be in one of several pre-defined formats. For each,

i have recorded
in Excel a macro that performs the necessary re-

formatting. I have
stored these as strings in a table. I want to:
1) based on user choice, create a spreadsheet in one of

the possible
formats,
2) open it and then play the appropriate macro

My VBA code (in Access) looks like this:

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open( ... Name of

spreadsheet ... )

Now, if the text of the macro is in a string variable

(call it
strMacro), what do i call in the Excel object model to

execute it ?


.