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

Opening a specific Word document from a text box 1

Status
Not open for further replies.

InkyRich

Technical User
Aug 2, 2006
126
GB
Hi all,
I am trying to open an existing specific Word document from a double click in a text box on a form. This document (which already exists) is selected from the entry in the text box on the double click.
I have tried various methods to no avail. Can anyone suggest how this might be done please?


Hampshire UK.

There is nothing so sad as an old guy trying to code.
 
It would be helpful if you posted your code; otherwise all anyone can do is play a guessing game - not.

Cheers
Paul Edstein
[MS MVP - Word]
 
You can use this [tt]OpenDocument[/tt] logic to open any document in its default app: [wiggle]

Code:
Option Explicit

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)[blue]
Call OpenDocument(TextBox1.Text)[/blue]
End Sub

Private Sub UserForm_Activate()
TextBox1.Text = "C:\SomeFolder\SomeFile.jpg"
End Sub
[blue]
Public Sub OpenDocument(strDocPath As String)
Dim G As Long
G = Shell("RUNDLL32.EXE URL.DLL,FileProtocolHandler " & strDocPath, vbNormalFocus)
End Sub[/blue]


---- Andy

There is a great need for a sarcasm font.
 
Thanks a lot Andy. I will give it a try.

Hampshire UK.

There is nothing so sad as an old guy trying to code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top