How to open a document invisibly to the user

Article contributed by Astrid Zeelenberg

In Word 2000, you can use Documents.Open Visible:=False. However, doing this was buggy until Word 2000 Service Release 1 came out – see: Word 2000 documents opened or created with the Visible:=False parameter can't be made visible again, and/or don't trigger a Close Event.

Word 97, doesn't have a Visible:=False parameter for the Open method, but you can use GetObject to match this behaviour (and it is bug-free!):

Dim oWordDoc As Word.Document

  'Open the document with GetObject (so it's invisible)
  Set oWordDoc = GetObject("C:\Name Of Document.Doc")

  'Write text to the bookmark 'FirstBookmark' in this document
  oWordDoc.Bookmarks("FirstBookmark").Range.Text = "New Text"

  'Save the document
  oWordDoc.Save

  'Close the document
  oWordDoc.Close
  Set oWordDoc = Nothing