View Single Post
  #1   Report Post  
Posted to comp.databases.ms-access,microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default access 97 to excel 97: execute macro automation

Assuming macro1 is a vba macro rather than a Excel4 style macro on an Excel4
macro sheet change this line

appExcel.ExecuteExcel4Macro "Macro1"

to

appExcel.Run "macro-test.xls!Macro1"

Regards,
Tom Ogilvy


JMCN wrote in message
om...
hello

i am trying to open an excel worksheet and excute a macro. i am able
to launch excel but i cannot execute the macro(s). why? what did i
leave out? should i create a getobject function? suggestions would be
appreciated:)
thanks jung

here is the code.

Public Sub LaunchExcel()
Dim appExcel As Excel.Application, strwks As String
Set appExcel = CreateObject("Excel.Application")
Msg "Excel is running"
appExcel.Visible = True
strwks = "c:\Program Files\Microsoft Office\Office\"
strwks = strwks & "macro-test.xls"
appExcel.ExecuteExcel4Macro "Macro1"
Set appExcel = Nothing
End Sub