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
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