Hi,
I'm using the code below to open a Word Doc from Access. The code works however Word opens in the background and I get complaints that it isn't working when in fact it is open in their task bar. Is there a way to change the code so the document opens on top of Access so to speak or is there better code to use?
Thanks,
Leesha
Open Word Doc From Access
-
- Administrator
- Posts: 78416
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- BronzeLounger
- Posts: 1484
- Joined: 05 Feb 2010, 22:25
Re: Open Word Doc From Access
I really need to get some sleep!
Code: Select all
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "C:\Trinity Solutions\TrinitySolutionsDatabaseFiles\Directions\ImportPersoanlClientData\Import Personal Data Directions.docx"
If Dir(LWordDoc) = "" Then
MsgBox "Document not found."
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=LWordDoc
End If
-
- Administrator
- Posts: 78416
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Open Word Doc From Access
Insert the line
just above End If. Does that work?
Code: Select all
oApp.Activate
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1484
- Joined: 05 Feb 2010, 22:25
Re: Open Word Doc From Access
You are awesome!! That did the trick!
Thanks so much,
Leesha
Thanks so much,
Leesha