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

How to print a word document from Access

P: 2
I have multiple documents that need to be printed on a daily basis and I want to create a Access form with buttons to print these documents.

I've created a form to open a word doc(s), but all I really need to do is just print the document.

I've got to imagine it's pretty simple, but I can't find anything in my searches to help me out.

Any ideas?
Mar 15 '10 #1
Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,769
Opening a document in Word is relatively straightforward. There may even be a way (I expect there is - but it's not Access technical) to open it and print it immediately. If not however, you'll need to open it under the control of the Access code. This is a different issue altogether and requires Application Automation.
Mar 15 '10 #2

P: 2
I've been able to find the code to print a Word doc from Access:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Set objWord = CreateObject("Word.Application")
  3. objWord.Visible = True
  4. Set objDoc = objWord.Documents.Add()
  5.  
  6. objWord.PrintOut , , , , , , , , , , , , "D:\Documents and Settings\jpapke\Desktop\macrotester.doc"
  7.  
  8. objWord.Quit
  9.  
  10. End Sub
Two other issues I must tackle are;

1) telling what tray to pull the paper from (I need it to pull tray #2 because it's yellow paper). I believe this is handled right after the PrintOut method above and should take the place of one of the "commas"

2) the other issue is that it's printing the "Document Settings" page after each time that I print. Any ideas on how to tell it to stop that?

Thank you,
Jay
Mar 15 '10 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
You can set the printer by using:
Expand|Select|Wrap|Line Numbers
  1. objWord.ActivePrinter = "CutePDF Writer"
I find that If I want to do stuff in Word or excel, the easiest is to start a macro recording, do the stuff I want, then stop the recorder and view the code. It might need small adaptations to work from within Access, but your 90% of the way there after looking at the macro.

That said, I don't know how to switch around the tray (Paper Source) :)
Mar 15 '10 #4

NeoPa
Expert Mod 15k+
P: 31,769
@omajay
I don't believe so Jay. This is so easy to check though. Simply use the help system for the Application.PrintOut method. That lists all the parameters available, and what they are for. I did it already though, and I didn't find anything there to control which tray to use. You should really consider checking things out in Help before posting a question.
Mar 15 '10 #5

Post your reply

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