Open Word + Document using a button?

TidusBlade

Watermelon Knight
Local time
Today, 21:55
Joined
Jan 26, 2009
Messages
6
I was wondering if it's possible to a button with VB code that opens up Microsoft Word with a document already sitting there, so the button always opens up Word and the same document? I tried googling and the only solution I found was opening Word only.

I was thinking if it's possible to let VB send some sort of signal to Windows and tells it to handle file x, which it will open with Word, much like clicking on the document itself in Explorer.

Really stuck on this one, so any help would be appreciated :)
Thanks!
 
There are many examples of doing so here. You simply need to pass the name of the file you want to open as an argument.
 
You need to use Shell() to do this. Here's an example that loads Word 2003 and opens a document named AccessTips.doc in the folder C:\Appointmentbook\tips.

Code:
Call Shell("C:\program files\Microsoft Office\Office11\winword.exe C:\Appointmentbook\tips\AccessTips.doc", 1)

You will have to substitute the actual path to your copy/version of Word as well as the path/filename for your document.
 
Hi I am having trouble getting this to work I have check the path for word.

I think it is because I have gaps in the file path.
Code:
Call Shell("V:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE  L:\Best Practice Manual\Full Labour Hire Best Practice Manual.doc", 1)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom