Results 1 to 20 of 23

Thread: Referencing a Word document that is already open

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,273
    Location
    Try:
    Dim AppWd As New Word.Application
     Dim WdDoc As Word.Document, WdRng As Word.Range
      
     Set WdDoc = AppWd.Documents.Open("C:/test.docm")
    You can now reference the document any time you need, via WdDoc. For example:
    Set WdRng = WdDoc.Sections(1).Range
    sets WdRng to span only the first Section in what may or may not be a multi-Section document. Having dealt with that, you might want to do something to the entire document, for which you'd reset WdRng:
    Set WdRng = WdDoc.Range
    Last edited by macropod; 08-17-2017 at 04:09 PM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •