Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a worksheet in excel.
I also have a word document (saved in the same directory), which has links with the details on this worksheet. I have added a command button with the intention that the user will be able to click on the button and invoke the word document. What code do I need to use in order to do this, or is there another way around this? Any help appreciated. Thanks in advance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, you have to establish a reference to the Word 11.0 Object library from
the Visual Basic Editor (Tools/References). Assuming the button on the worksheet is named btn_Run and the Word document is named Test.doc, the following code will open the Word document in the same location as the worksheet. Private Sub btn_Run_Click() Dim WordDoc As Word.document Dim path As String 'The "path" variable is the location of the workbook path = Application.Workbooks("TestWKB.xls").path 'Open Word document Set WordDoc = Word.documents.Open(path & "\test.doc") 'Close Word document WordDoc.Close End Sub "Sarah (OGI)" wrote: I have a worksheet in excel. I also have a word document (saved in the same directory), which has links with the details on this worksheet. I have added a command button with the intention that the user will be able to click on the button and invoke the word document. What code do I need to use in order to do this, or is there another way around this? Any help appreciated. Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to get userform Cancel button to invoke Exit Sub in calling macro? | New Users to Excel | |||
Help needed in updating excel worksheet values | Excel Worksheet Functions | |||
How to invoke a user form from a custom button on the menu bar | Excel Programming | |||
Importing Excel Worksheet into word... help needed! | Excel Discussion (Misc queries) | |||
Turning Excel Worksheet Linked to Word Document into Report Templa | Excel Programming |