title: VBA Modules and passing arguments
body: <p>I have a module that can be called from any part of my application to check if a particular font is installed on the users system, and if not - install the font and check again before continuing</p>
  
  <p><strong>Main Applicaton</strong></p>
  
  <pre><code>if RequiredFont.Run(strFontName) = FALSE Then '(error message and exit sub)
  </code></pre>
  
  <p><strong>Module "RequiredFont"</strong></p>
  
  <pre><code>Public Function Run(Font As String) As Boolean
      if check(Font) = FALSE Then
          Run = FALSE
          Install(Font)
          if check(Font) = TRUE Then Run = TRUE
      Else
          Run = TRUE
      End If
  
  
  Private Function Check(Font as String) as Boolean
  'code to check the font exists on the users localmachine, returns true/false
  End Sub
  
  Private Sub Install(Font as String)
  'code to install the font on the users localmachine,
  End Sub
  </code></pre>
  
  <p>My first question is:</p>
  
  <p>Is the best way to make arguments available to all functions and subs, to pass them through each time I call? (as shown above).... or is there a simple way to declare an argument as variable to the whole module when Run() is called?</p>
  
  <p>My Second Question is:</p>
  
  <p>Is there a way I can avoid Run() alltogether and just call the module name "RequiredFont" directly, I remember that in other languages, calling a sub by a certain name would automatically run that sub when the module is called</p>
  
  <p>Thank You</p>
  
  <p>EDIT - This is how my code looks now:</p>
  
  <pre><code>Private FontName As String
  Private FontFile As String
  
  
  Public Function Run(strFontName As String, strFontFile As String) As Boolean
  
      FontName = strFontName
      FontFile = strFontFile
      Run = False
  
      If CheckFont() = False Then InstallFont
      If CheckFont() = True Then
          Run = True
      Else
          'message error"
      End If
  
  End Function
  
  
  Private Function CheckFont() As Boolean
      'code to check if the font is installed
      On Error Resume Next
      'Create a temporary StdFont object
      With New StdFont
          ' Assign the proposed font name
          .Name = FontName
          ' Return true if font assignment succeded
          If (StrComp(FontName, .Name, vbTextCompare) = 0) = False Then
              CheckFont = False
          Else
              CheckFont = True
          End If
      End With
  End Function
  
  Private Sub InstallFont()
  ' code to install the font
      MsgBox "You need the following font installed to continue." _
      &amp; vbNewLine _
      &amp; vbNewLine &amp; "'" &amp; FontName &amp; "'" _
      &amp; vbNewLine _
      &amp; vbNewLine &amp; "Click OK to launch the font. Please click the INSTALL button at the top"
      OpenFile (PATH_TO_FONTS &amp; FontFile)
  
  End Sub
  </code></pre>