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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open OLE object via code 1

Status
Not open for further replies.

sozzer

Technical User
Apr 4, 2005
73
0
0
GB
I have a Word document in a field in a table. I've looked around but cant find how i can open this via code, ie on click of a button.

I currently have the following which referneces from a specific path name, but ideally i'd like the Instructions file to be packaged within the db, hence my question.
Code:
Dim strDocPath As String
Dim dbs As Database
Dim objApp As Object

On Error GoTo err1
strDocPath = "c:\program files\scoms\Instructions.doc"
Set objApp = GetObject(, "Word.Application")
With objApp
.Documents.Open (strDocPath)
.ActiveDocument.PrintPreview
.Visible = True

End With
Set objWord = Nothing
err1:
If Err.Number = 429 Then
    Set objApp = CreateObject("Word.Application")
    objApp.Visible = True
    Resume Next
End If
I'm assuming this is fairly easy to do....?

cheers
Ad
 
I think you can set this in the auto active property of the ole-object, like

Auto-Activate: Double-Click

Pampers [afro]
Just let it go...
 
thanks pampers. i want it to launch from a command button on a form so your suggestion pointed me in the right direction:

file1 is the control name and is visible = no

With Me
.file1.Action = acOLEActivate
.file1.Verb = acOLEVerbOpen
End With


However, word doesnt open the first time you click the button - the control becomes visible and it opens the doc within the control. Press it again, and the doc opens in Word as it should. Any ideas?
 
sorry Sozzer, I don't know.

Pampers [afro]
Just let it go...
 
Doh! Simple but effective. Have a star for pointing out the obvious to me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top