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!

Word button coding

Status
Not open for further replies.

Flammer

Technical User
Jan 30, 2001
10
GB
OK I need to open a document via a button which is located in an OLE source.

So far I have got this to work but need the coding for the actual document to be universal so it will always open the docment which is in the OLE Source.

Can anyone help?

Private Sub Command50_Click()
On Error GoTo Err_Command50_Click
' Button launches Word and opens a specified document
' And runs an optional macro. the macro could print out the word doc and quit

Dim retval As Variant
Dim DocName, MacroName As String
' Drive and Full path to name and location of Word document
DocName = "F:\Somefolder\MyDoc.doc"

'Note full path to Word including Drive and folder
retval = Shell("c:\Program Files\Office\WinWord.exe" & " " & DocName & MacroName, vbNormalFocus)

Exit_Command50_Click:
Exit Sub

Err_Command50_Click:
MsgBox Err.Description
Resume Exit_Command50_Click

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top