Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to open Excel from a Word document

Status
Not open for further replies.

beanbag

Instructor
Dec 3, 2001
5
US
I have a form in Word where data is linked into it from an Excel worksheet. I would like to write a macro and assign it to a button in Word that will automatically open the Excel worksheet. The form has a large number of calculation in it and seems to perform better when linked with Excel.

I have not figured out how to write the macro to open the Excel application and a specific worksheet.

Any suggestions would be helpful.
 
Just add the MS Excel Object Library to your Project>References and tweak this code as needed.

Note the ReadOnly setting. Set to False if the worksheet can be changed.
Code:
Workbooks.Open FileName:="C:\test.xls"
Workbooks.Application.Visible = True
Sheets("Sheet1").Select
Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top