title: Strange behavior of VBS/VBA Script (working only on some machines, on others Word is crashing)
body: <p>I have a problem with one of my scripts.
  I Inject a Public-Sub Routine into the users Normal.dotm (into "ThisDocument").
  The Script is working fine, but only one some clients.
  (On the clients where it doesn't work, the Word Process is crashing, see below...)
  I would be nice if an experienced programmer can have a look at my coding, or tell me how to debug what's going wrong.
  All variables are correctly filled and the clients are all Win7 Enterprise with same Policys. The normal.dotm is also in the same place on every machine. • „Trust access to the VBA project object model“ is set on all clients.</p>
  
  <p>Any Ideas?</p>
  
  <p>Here's the full coding:</p>
  
  <pre><code>' 22.04.2015 
  ' Imports the CRM WordMerge Function into the Normal.dot
  
  
  ' Homefolder als Variable bereitstellen
  
  Set oShell = CreateObject("WScript.Shell")
  
  strHomeFolder = oShell.ExpandEnvironmentStrings("%APPDATA%")
  ' wscript.echo strHomeFolder
  
  ' Auslesen des aktuellen Verzeichnisspfades
  
  scriptdir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
  ' WScript.Echo scriptdir
  
  ' Get current User
  Set objNetwork = CreateObject("Wscript.Network")
  
  ' Backup der Originalen Normal.dotm
  
  dim filesys
  
  set filesys=CreateObject("Scripting.FileSystemObject")
  
  ' Existierendes Backup löschen
  If filesys.FolderExists(scriptdir &amp; "\Backup\" &amp; objNetwork.UserName) Then
  filesys.DeleteFolder scriptdir &amp; "\Backup\" &amp; objNetwork.UserName
  end if
  
  ' File mit Pfad zur normal.dotm einlesen:
  strdatei=scriptdir &amp; "\Path\path.txt"
  Const ForReading = 1
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objTest = objFSO.GetFile(strdatei)
  If objTest.Size &gt; 0 Then
  Set objFile = objFSO.OpenTextFile(strdatei, ForReading)
  strText = objFile.ReadAll
  strText = oShell.ExpandEnvironmentStrings(strText)
  'wscript.echo strText
  objFile.Close
  end if 
  
  
  
  
  
  If filesys.FileExists(strText) Then
  ' MsgBox(scriptdir &amp; "\Backup\" &amp; objNetwork.UserName)
  filesys.CreateFolder scriptdir &amp; "\Backup\" &amp; objNetwork.UserName
  filesys.CopyFile strText, scriptdir &amp; "\Backup\" &amp; objNetwork.UserName &amp; "\"
  end if
  
  
  
  const wdDoNotSaveChanges = 0
  
   WScript.Echo "Installing FrNow Macro for Word..."
  ' Dim oApplication, doc
  Dim oApplication, doc
  Set oApplication = CreateObject("Word.Application")
  
  ' WScript.Echo "Opening Normal.dot Template..."
  oApplication.Documents.Open strText
  Set doc = oApplication.ActiveDocument
  
  Dim comp, components
  Set components = oApplication.ActiveDocument.VBProject.VBComponents
  
  
  ' Importiere CRM Makro
    oApplication.ActiveDocument.VBProject.VBComponents("ThisDocument").CodeModule.AddFromFile(scriptdir &amp; "\Import\FrNow.cls")
  
  WScript.Echo "Installation Finished..."
  
  doc.close wdDoNotSaveChanges
  
  oApplication.Quit wdDoNotSaveChanges
  </code></pre>