title: Word VBA: share variable between ThisDocument class module and a regular module?
body: <p>In Word 2013, I need to share a variable (ccID) between ThisDocument and a regular module. Here's the code:</p>
  <p>&quot;Project (Toto)&quot; → &quot;Microsoft Word Objects&quot; → &quot;ThisDocument&quot;:</p>
  <pre><code>Option Explicit
  
  Public Sub Document_ContentControlAfterAdd(ByVal NewContentControl As ContentControl, ByVal InUndoRedo As Boolean)
  
      Static ccID As String
      Dim alertTime As Variant
      
      ' You can't affect document content while within this event, so save CC ID and create a timer that calls code to execute after the event has finished.
      ccID = NewContentControl.ID
      alertTime = Now + TimeValue(&quot;00:00:01&quot;)
      Application.OnTime alertTime, &quot;UpdateContentControl&quot;
  
  End Sub
  </code></pre>
  <p>&quot;Project (Toto)&quot; → &quot;Modules&quot; → &quot;Module1&quot;:</p>
  <pre><code>' Give any newly-added content control a yellow background for user-friendliness
  ' (Called by ThisDocument -&gt; Document_ContentControlAfterAdd)
  
  Public Sub UpdateContentControl()
  
  MsgBox (&quot;UpdateContentControl started&quot;)
      ActiveDocument.ContentControls(ccID).Range.Shading.BackgroundPatternColor = wdColorYellow
  
  End Sub
  </code></pre>
  <p>When UpdateContentControl runs, ccID is out of context. How can I share a variable between code in ThisDocument and a regular module?</p>