Prev: Writing a macro to delete specific lines from a large Word document
Next: Insert value in cells and combined them
From: Stanley on 24 Mar 2010 15:28 I am trying to open a Word document from an Access program using the following code: objWord.Documents.Open path\FileName objWord.Documents(1).Activate I can't get the Word document open on my desktop. What am I doing wrong? Thanks, Stanley
From: Doug Robbins - Word MVP on 24 Mar 2010 18:08 You should show us all of the code so that we can see what you have set objWord to. Assuming that you have used something like Set objWord = GetObject(, "Word.Application") or Set objWord = CreateObject("Word.Application") then having declared docWord as a Word.Document, try Set docWord = objWord.Documents.Open("path\File") docWord.Activate -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Stanley" <Stanley(a)discussions.microsoft.com> wrote in message news:ADBB3BA2-7233-4A76-A968-3DD64E2C5DD4(a)microsoft.com... > I am trying to open a Word document from an Access program using the > following code: > objWord.Documents.Open path\FileName > objWord.Documents(1).Activate > I can't get the Word document open on my desktop. > What am I doing wrong? > Thanks, > Stanley
From: Fumei2 via OfficeKB.com on 29 Mar 2010 14:29
Set docWord = objWord.Documents.Open("path\File") as long as it is not followed by any instructions on another document, does not require an Activate. It makes the just opened document the ActiveDocument. Further, in most cases Activate is not even needed, as working with the document object (docWord) allows access to all properties of the document. Doug Robbins - Word MVP wrote: >You should show us all of the code so that we can see what you have set >objWord to. > >Assuming that you have used something like > >Set objWord = GetObject(, "Word.Application") > >or > >Set objWord = CreateObject("Word.Application") > >then having declared docWord as a Word.Document, try > >Set docWord = objWord.Documents.Open("path\File") >docWord.Activate > >> I am trying to open a Word document from an Access program using the >> following code: >[quoted text clipped - 4 lines] >> Thanks, >> Stanley -- Gerry Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/word-programming/201003/1 |