Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Find the last opened instance of Word

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming
View previous topic :: View next topic  
Author Message
Kathy Webster
Guest





PostPosted: Fri Nov 09, 2007 9:40 pm    Post subject: Find the last opened instance of Word Reply with quote

I'm running vb code from MSAccess. I want the code to find the last opened
window of Word and do something to the document that is on that Word screen.

Help!
TIA,
Kathy
Back to top
Google
Sponsor





PostPosted: Fri Nov 09, 2007 9:40 pm    Post subject: Advertisement

Back to top
fumei via OfficeKB.com
Guest





PostPosted: Sun Nov 11, 2007 6:28 am    Post subject: Re: Find the last opened instance of Word Reply with quote

What do you mean by "last opened"?

ActiveDocument is the object for the active document.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200711/1
Back to top
Kathy Webster
Guest





PostPosted: Sun Nov 11, 2007 10:35 pm    Post subject: Re: Find the last opened instance of Word Reply with quote

Each time you open a document in word, it opens each document in a separate
window. I want to write VB code that will go to the last window/document
that was opened by word. The code will be starting from Microsoft Access.

"fumei via OfficeKB.com" <u37563@uwe> wrote in message
news:7b0a6472af292@uwe...
Quote:
What do you mean by "last opened"?

ActiveDocument is the object for the active document.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200711/1
Back to top
Doug Robbins - Word MVP
Guest





PostPosted: Sun Nov 11, 2007 10:54 pm    Post subject: Re: Find the last opened instance of Word Reply with quote

You would probably be better off having your Access code create a new
document for whatever purpose it is required.

In Access

Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Add("Template Path\Name")
With doc
'Whatever you want to do with the document
End With
Set doc = Nothing
Set appWord = Nothing



--
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

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:473783b2$0$20568$4c368faf@roadrunner.com...
Quote:
Each time you open a document in word, it opens each document in a
separate window. I want to write VB code that will go to the last
window/document that was opened by word. The code will be starting from
Microsoft Access.

"fumei via OfficeKB.com" <u37563@uwe> wrote in message
news:7b0a6472af292@uwe...
What do you mean by "last opened"?

ActiveDocument is the object for the active document.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200711/1


Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum