Open Word Document from Excel Userform

M

Myrna Rodriguez

Happy New Year!

What is going on?

My scenario:
I have an Excel Userform with 2 command buttons.
Commandbutton 1: opens an excel file (this works)
Commandbutton 2: NEEDS to open a word document (problem)

How can I open a word document from this Excel Userform?
Does Excel open Excel related files only?

This is the code to open the Excel file: (this works)
Private Sub cmd1_Click()
ChDir "J:\Myrna"
Workbooks.Open Filename:="J:\Myrna\openexcel-1.xls"
End Sub

This is the code to open the word file: (problem)
Private Sub cmd2_Click()
ChDir "J:\Myrna"
Workbooks.Open Filename:="J:\Myrna\openword-1.doc"
End Sub
Thanks in advacnce for your help & have a happy day!
 
G

Guest

Private Sub cmd2_Click() Dim WordObj As Object

Set WordObj = CreateObject("Word.Application")

WordObj.Documents.Open ("J:\Myrna\openword-1.doc")

WordObj.Visible = True

Set WordObj = Nothing
End Sub


HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top