Skip to content

Instantly share code, notes, and snippets.

@tdalon
Last active November 28, 2024 07:52
Show Gist options
  • Save tdalon/3876eb7a386664f6afa37d845d90d3c7 to your computer and use it in GitHub Desktop.
Save tdalon/3876eb7a386664f6afa37d845d90d3c7 to your computer and use it in GitHub Desktop.
Excel VBA global property example
Private pLocalPath As String
Public Property Get LocalPath() As String
If pLocalPath = "" Then
pLocalPath = GetLocalPath(ThisWorkbook.Path)
End If
LocalPath = pLocalPath
End Property
' Using Property somewhere else in VBA - example
Function GetModuleLocalPath(Name As String, rel As String) As String
sRootDir = LocalPath & "\" & rel & "\" & Name
GetModuleLocalPath = sRootDir
End Function
' UDF Function to be called from Excel Sheet
Function GetProp_LocalPath()
GetProp_LocalPath = LocalPath
End Function
@tdalon
Copy link
Author

tdalon commented Nov 28, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment