title: If statement within VBscript function not working
body: <p>I am hoping someone can help me possibly debug the below code, as I am confused as to why it is happening.</p>
  
  <p>I have a fairly simple VBScript that runs when a user logs onto a server/PC, that will create some signatures based on their active directory details. I have decided to move each section of the signature creation into a function, in order to make things a bit easier when creating new signatures.</p>
  
  <p>Here is the function I am having issues with:</p>
  
  <pre><code>'Function to add job title and company
  Function AddTitle
      objSelection.Font.Name = "Calibri"
      objSelection.Font.Bold = False
      objSelection.Font.Italic = False
      objSelection.Font.Size = "11"
      objSelection.Font.Color = RGB(0,0,0)
      If(strTitle) Then
          objSelection.TypeText strTitle &amp; Chr(11)
      End If
      objSelection.TypeText strCompany &amp; Chr (11)
  End Function
  </code></pre>
  
  <p>Now, when calling the function later on using:</p>
  
  <pre><code>'Add job title and company
  AddTitle
  </code></pre>
  
  <p>It ignores the section within the If statement. I know that some variables need to be defined globally for them to work in a function, and strTitle is definitely defined at the beginning of my script.</p>
  
  <p>Am I missing something totally obvious, as the section inside the if statement functions correctly if taken out of the if statement. Likewise, If I were to add the if statement to my script inline, and take it out of the function, it works correctly.</p>
  
  <p>It is only when running from the Function.</p>