Trouble accessing MSWord ActiveDocument

Posted by Adam Tegen on Stack Overflow See other posts from Stack Overflow or by Adam Tegen
Published on 2008-12-16T20:31:30Z Indexed on 2010/04/06 6:03 UTC
Read the original article Hit count: 601

Filed under:

When I try to programmatically access a word object model, I get an error no document is active. This appears to be because I am loading the document as not visible using Word automation, and I have to keep it invisible.

How would I code the open macro so that it does nothing in this case? "If Not ActiveDocument is Nothing Then" didn't work.

Private Sub Document_Open()

   If (ActiveDocument.SaveFormat = wdFormatRTF) Then
      'Do some stuff
   End If

End Sub

© Stack Overflow or respective owner

Related posts about msword