Group:  Microsoft Access ยป microsoft.public.access.interopoledde
Thread: Launch Word from Access - problem in Vista

Launch Word from Access - problem in Vista
Joaneee 4/28/2007 9:28:00 PM
I have an Access 2002 app that launches Word to print an envelope, when the
user clicks a button. To my surprise, this app still works fine with Vista
on my new computer, BUT...when Word launches, it remains invisible unless I
use Task Manager to switch to Word in order to print. The code I am using is:

Private Sub cmdWord_Click()
On Error GoTo Err_cmdWord_Click
Dim MyWord As Object
Dim WordWasNotRunning As Boolean

' Test to see if there is a copy of Microsoft Word already running.
On Error Resume Next ' Defer error trapping.
Set MyWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then WordWasNotRunning = True
If WordWasNotRunning Then
Err.Clear
Set MyWord = GetObject("<path>\Envelope.doc")
WordWasNotRunning = False
End If
MyWord.Activate
MyWord.Application.Visible = True
MyWord.Parent.Windows(1).Visible = True

Exit_cmdWord_Click:
Exit Sub

Err_cmdWord_Click:
MsgBox Err.Description
Resume Exit_cmdWord_Click

End Sub

This code used with Windows XP made Word visible without invervention. Any
ideas?
Thanks in advance.
(btw, Vista Home Premium, Office Pro XP, new computer with Vista
pre-installed)
--
Joaneee

Home | Search | Terms | Imprint
Newsgroups Reader