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

Hi, Can you show me how I can open

Status
Not open for further replies.

Greaser

Technical User
Aug 1, 2001
84
0
0
CA
Hi,
Can you show me how I can open a Word file from an event procedure (button OnClick)?
Thanks,
John
 
Two ways;
1. Assign a hyperlink to the button
2. use Shell() Call Shell(&quot;Winword.exe <path and filename>&quot;)
 
In the propeties dialog double click in the 'onClick' event option. You will be shown options one of which is the Macro buider. If you select this the macro editor will be opened. Click in the left hand column and you will see a drop down box of all the macros available. Select the one called RunApp. At the bottom of the form you will see a text box called command line. Type in the full name and path of the document to open.
Alternately select the Code Builder option it will open the VB editor with a event handler stub. In the tools menu click on references and find the item which refers to MS Word, tick it then click OK. (the exact name varies depending on version installed).
Add the following to the stub

Dim WdApp as Word.Application

Set WdApp = getobject(&quot;Path\File.doc&quot;)
if WdApp is Nothing then
msgbox(&quot;Unable to open file&quot;)
exit sub
endif

important (depending on what you want to do)
WdApp.visible = true

If you use the second method you can write to the word doc from access, say to enter data from a table and can totaly control it from access. If you just want to read the file the macro is probably sufficient

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top