View Single Post
 
Old 11-24-2020, 01:15 PM
Charles Kenyon Charles Kenyon is online now Windows 10 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,469
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

In a Global Template, the following works and the variable value persists so long as the template is loaded. The code is in a standard module.

Code:
Option Explicit
Public strTest As String

Static Sub AutoExec()
    Let strTest = "This is a test"
End Sub

Sub TestStringVar()
    MsgBox strTest
End Sub
Here is a link to the template: Public Variable Test.dotm


Using Document Variables is likely easier in global templates (as set forth earlier). That is what I've done in the past.
Reply With Quote