Button needed in worksheet to invoke word doc with linked values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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

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

Back
Top