Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a Word Documen in Access 2

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
Hope this is the correct forum. I need to open a word document in Access 2010. The document contains help information and has some screen shots in it. Using the follwing code in "on click" event of a button:

Dim LWordDoc As String
Dim oApp As Object

'Path to the word document
LWordDoc = "x:\ddp\ddp_info\stuff.doc"

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

Problem is, word opens but displays the document behind Access, and you can open it by hitting the Windows Icon on the task bar. I need it to opn on top of ACCESS.

Thanks in advance.

jpl
 
This works well to open any file in its default application without instantiating the app object in code:
Code:
Dim G As Long
Dim strDocPath As String
strDocPath = the fully qualified path to the document to be opened
G = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & strDocPath, vbNormalFocus)


Beir bua agus beannacht!
 
I'd use the AppActivate instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
genomon - Thanks, it worked fine.

jpl
 
genomen, does that give you any trouble if there is a long file name with spaces in it?
 
Not sure how big of a string the dll will take. Typically 255 chars.
Spaces shouldn't be a problem.

Beir bua agus beannacht!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top