+ Reply to Thread
Results 1 to 3 of 3

Open Word Document from Excel Userform

  1. #1
    Myrna Rodriguez
    Guest

    Open Word Document from Excel Userform

    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
    >>>ERROR MESSAGE: runtime error: file format is not valid


    Thanks in advacnce for your help & have a happy day!



    *** Sent via Developersdex http://www.developersdex.com ***

  2. #2
    Gary L Brown
    Guest

    RE: Open Word Document from Excel Userform

    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,
    --
    Gary Brown
    gary_brown@ge_NOSPAM.com
    If this post was helpful, please click the ''Yes'' button next to ''Was this
    Post Helpfull to you?''.


    "Myrna Rodriguez" wrote:

    > 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
    > >>>ERROR MESSAGE: runtime error: file format is not valid

    >
    > Thanks in advacnce for your help & have a happy day!
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >


  3. #3
    Myrna Rodriguez
    Guest

    RE: Open Word Document from Excel Userform

    Thanks much for your help!
    It works very smooth.

    happy day!!

    *** Sent via Developersdex http://www.developersdex.com ***

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1