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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a Word file inside Excel

Status
Not open for further replies.

Sopman

Technical User
Mar 21, 2001
206
US
In excel, how can I open a Word file. I would like to click on a "button" (from the FORMS Toolbar) that has a macro assign to open the file. I'm having troubles with the macro. I've tried making the macro using the mouse to open a file, but it's not working.

Can someone help??

Thanks
 
Assign the macro code to the button along the lines of below:
(I am assuming you know the VBE editor etc for assigning macros)

Make sure that you have the references for Word enabled

sub Main()

'dim a new word object
Dim appWD As New Word.Application

'open Winword
Set appWD = CreateObject("Word.Application")

'open new document based on template (if applicable)
appWD.Documents.Add Template:= "C:\Program files\Microsoft Office\Templates\Template Name, newtemplate:=false

'show new doc
appWD.Visible = True

'add all other code here

end sub
 
Hi there

What about using a hyperlink in a cell, which will refer to the file location, and will open the file as required with Word, by clicking on the hyperlink (See "hyperlink" in the help file)

Pieter
 
The easiest way to do this is to record a macro do open (I am assuming you are opening up the same document everytime).

1. TOOLS->MACRO->RECORD MACRO. Give the macro a name.

2. INSET->OBJECT->CREATE FROM FILE->BROWSE. Select the file and click on INSERT then OK

3. Stop the recording.

Thats it. Everytime you run the macro, it will insert the same file.

The other option (rather than inserting the file everytime), if all you want to do is update the content is follow step 2 above (ignore step 1). Then, before you click on OK, check the check box LINK TO FILE.

Now, everytime you make a change to the document you have just inserted, the content in the Excel file will also change. Automatically.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top