PC Review


Reply
Thread Tools Rate Thread

Button needed in worksheet to invoke word doc with linked values

 
 
=?Utf-8?B?U2FyYWggKE9HSSk=?=
Guest
Posts: n/a
 
      23rd Jul 2007
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 With Quote
 
 
 
 
=?Utf-8?B?Q2hhZA==?=
Guest
Posts: n/a
 
      23rd Jul 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed in updating excel worksheet values =?Utf-8?B?c2FkYXQ=?= Microsoft Excel Worksheet Functions 1 7th Jun 2007 06:27 AM
Referencing Word field contents in a linked Excel worksheet =?Utf-8?B?U25pcGVyNjY=?= Microsoft Word Document Management 1 3rd Oct 2006 10:25 AM
Macro needed to transfer numerical values in cell from one worksheet to another slcidc@hotmail.com Microsoft Excel Programming 3 24th Jul 2006 09:09 AM
Create button on worksheet to restore woksheets orignal values =?Utf-8?B?QnJpYW4=?= Microsoft Excel Worksheet Functions 1 29th Mar 2006 03:20 AM
Need help formatting 'linked Excel worksheet objects' in Word so . =?Utf-8?B?Y29uZGxpZmZl?= Microsoft Word Document Management 1 12th Nov 2004 06:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 PM.