By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 921 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Code on Button to Open MS Word File

P: 13
Hi, Can anyone help me write a code on the Button to Open a MS Word File.

Thanks
May 7 '07 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,347
Hi, Can anyone help me write a code on the Button to Open a MS Word File.

Thanks
Yes, we can help.

You can use Call Shell "..."
to open up a file, you just have to work out the correct command line argument.

Or

You can dim and create a word application and then open a file. There is slightly more work involved in this.
May 7 '07 #2

ADezii
Expert 5K+
P: 8,619
Hi, Can anyone help me write a code on the Button to Open a MS Word File.

Thanks
Assuming the Default Installation of Microsoft Office (Office 2000), and the file you wish to open is Text.doc in the C:\Test\ Folder, then:
Expand|Select|Wrap|Line Numbers
  1. Dim retVal, strPathToWord As String, strDocumentName As String
  2.  
  3. strPathToWord = "C:\Program Files\Microsoft Office\Office\winword.exe "
  4. strDocumentName = "C:\Test\Test.doc"
  5.  
  6. retVal = Shell(strPathToWord & strDocumentName, vbMaximizedFocus)
NOTE: As stated by Rabbit, the other option is Automation which is more involved.
May 7 '07 #3

JConsulting
Expert 100+
P: 603
Assuming the Default Installation of Microsoft Office (Office 2000), and the file you wish to open is Text.doc in the C:\Test\ Folder, then:
Expand|Select|Wrap|Line Numbers
  1. Dim retVal, strPathToWord As String, strDocumentName As String
  2.  
  3. strPathToWord = "C:\Program Files\Microsoft Office\Office\winword.exe "
  4. strDocumentName = "C:\Test\Test.doc"
  5.  
  6. retVal = Shell(strPathToWord & strDocumentName, vbMaximizedFocus)
NOTE: As stated by Rabbit, the other option is Automation which is more involved.
this will work as well

FollowHyperlink "C:\Test\Test.doc"
May 7 '07 #4

P: 13
ssq
Thanks Guys, i am new to Access and i am learning quite a bit from you Guys!
Thanks Again.
May 7 '07 #5

ADezii
Expert 5K+
P: 8,619
this will work as well

FollowHyperlink "C:\Test\Test.doc"
Good point, JConsulting - forgot about that one!
May 7 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.