Invalid outside procedure

15,658

Put the variable in a module instead, like this:

Public path As String

Then, in your Workbook_Open routine:

Private Sub Workbook_Open()
    yourModule.path = "\\sharedDrive\TestFolder\Test_PDF\"
End Sub

To access it anywhere, use yourModule.path.

Share:
15,658
user793468
Author by

user793468

Updated on June 28, 2022

Comments

  • user793468
    user793468 almost 2 years

    I want to store a path in string "path" which would be available for the whole workbook.

    When I do it the following way, I get an error: "invalid outside procedure"

    Here is how I am trying to declare the path in (General) (Declaration)

    Option Explicit
    Dim path As String
    
     path = "\\sharedDrive\TestFolder\Test_PDF\"
    

    I get the error at:

    "\\sharedDrive\TestFolder\Test_PDF\"