I am manipulating several Word Documents from Access 2002. But efficiently
opening Word and the documents has eluded me. What I want is:
If Word is open use that instance, else open a new instance.
Then,
If the document is open, use it, else open it.
Fantasy-code looks like:
If IsOpen ("Word") = False Then Set objWord = New Word.Application
and,
If IsOpen ("MyDocument') then Open....
Can anyone suggest real code?
Many thanks
Mel - 23 Apr 2005 15:28 GMT
Here is a copy of the routine I use:
---------
'The Calling program has: Dim objWord As Object
Sub InitializeWord(objWord As Object)
Const wdWindowStateMaximize As Integer = 1
On Error Resume Next 'If Word is not already running, start it
Set objWord = GetObject(, "Word.Application")
If (Err <> 0) Then
Err.Clear
Set objWord = CreateObject("Word.Application")
End If
On Error GoTo PROC_ERR
objWord.Visible = True
objWord.CommandBars("Standard").Visible = True
objWord.CommandBars("Formatting").Visible = True
objWord.WindowState = wdWindowStateMaximize 'Maximize
Exit Sub
PROC_ERR:
MsgBox "The following error occurred: " & Error$
Resume Next
End Sub
----------
Regards,
Mel Woolsey
>I am manipulating several Word Documents from Access 2002. But efficiently
> opening Word and the documents has eluded me. What I want is:
[quoted text clipped - 12 lines]
>
> Many thanks