Quote:
Originally Posted by Guessed
As a public variable, its value will persist but you do need to run the macro to give it a value first. So you should rename the setProjectPath macro to Document_Open or Document_New as these will autorun with either opening an existing document or creating a new document respectively.
Alternatively, you could declare it as a constant.
|
My experience, tonight, disagrees. Perhaps I am just tired. I tried setting the value of a public variable declared outside a procedure and it blanked when I ran the second procedure trying to access that value.
Code:
Option Explicit
Public projectPath As String
Sub setFilePath()
Let projectPath = "This is my filepath"
End Sub
Sub ShowprojectPath()
MsgBox "projectPath = " & projectPath
End Sub
Andrew, I admit that I am out of my comfort zone here. I initially thought the same. You have more experience with this than I do.