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

Print a Word document from Access Form

Status
Not open for further replies.

newcoder54

Technical User
Jul 2, 2002
46
US
I need to have a function that will print a DOC file when I click on a button on a Access 97 form. I suppose Word has to open a bit, print and then close. The file has a specific name in a specific folder. Over my head at this point to do the code. Thanks much!
 
Try this:

Private Sub Command15_Click()

Application.FollowHyperlink "C:\Documents and Settings\ufga20.000\Desktop\Word1.doc"

End Sub


-Gary
 
Sorry, didn't thoroughly read you post. The FollowHyperlink solution is a simple one, but will not automatically print and close Word, the user will have to do that manually.

-Gary
 
You'll have to look at the keystrokes involved with Word but you can use "SendKeys" to try and do the printing and close Word. For example:

Application.FollowHyperlink "C:\Documents and Settings\ufga20.000\Desktop\Word1.doc"

SendKeys "^p" 'Print the document
SendKeys "~" ' Hit enter for the OK button
SendKeys "^q" ' Quit

I'll caution that this isn't pretty, especially on a slow system and can be prone to problems. (Like user interaction when they see Word open.)

Hope it helps.

-Emil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top