| View previous topic :: View next topic |
| Author |
Message |
Kathy Webster Guest
|
Posted: Fri Nov 09, 2007 9:40 pm Post subject: Find the last opened instance of Word |
|
|
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

|
Posted: Fri Nov 09, 2007 9:40 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
fumei via OfficeKB.com Guest
|
|
| Back to top |
|
 |
Kathy Webster Guest
|
Posted: Sun Nov 11, 2007 10:35 pm Post subject: Re: Find the last opened instance of Word |
|
|
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...
|
|
| Back to top |
|
 |
Doug Robbins - Word MVP Guest
|
Posted: Sun Nov 11, 2007 10:54 pm Post subject: Re: Find the last opened instance of Word |
|
|
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 |
|
 |
|