From: Stanley on
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
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
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