Calling a macro from a excel sheet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • canada18
    New Member
    • May 2010
    • 1

    Calling a macro from a excel sheet

    I am trying to call a macro written in excel and calling from VBA code. Macro is in worksshet within a workbook.
    Error message is : Object variable or with block variable not set
    Any idea what it is complaining about?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by canada18
    I am trying to call a macro written in excel and calling from VBA code. Macro is in worksshet within a workbook.
    Error message is : Object variable or with block variable not set
    Any idea what it is complaining about?
    Code:
    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    
    Set xlApp = New Excel.Application
    xlApp.Visible = True
    Set xlBook = xlApp.Workbooks.Open("C:\Test\Test.xls")
    
    'Run the macro
    xlApp.Run "Macro1"
    
    'Your choice
    'xlApp.Quit

    Comment

    Working...