Open Workbook From Macro Using Variables

  • When the "Workbooks.Open" method is executed from a Macro initiated by a keyboard shortcut the code following the open is not executed. When the same code is 'Run' in the VBA Edit window everything works just fine.

  • Re: In Macro Code

    As long as you are setting mypath1 correct and my name this should work:

    Sub Macro2()
    Dim MyPath1 as string, MyName as string
    MyName = 'whatever
        strVar = mypath1 & "/" & myname & ".xls"
        Workbooks.Open Filename:=strVar
         MsgBox "Hello World"
    End Sub
  • Re: Open Workbook From Macro Using Variables

    Thanks for the reply, and the code snippet, but that is more or less the code I am trying to exec and it does not work.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!