A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

From Access, print a word doc



 
 
Thread Tools Display Modes
  #1  
Old May 18th, 2004, 07:56 PM
RC
external usenet poster
 
Posts: n/a
Default From Access, print a word doc

Does anyone know a slice of VB code that would let me
print a specific word document by clicking a button in
Access? I have a request to print some standard handouts
in addition to every time we print a certain signup
report from Access. (this way all documents are at the
printer together, and we don't have to remember to pull
copies out of the file. Saves a lot of time.) In the
past I have imported the document into Access as a
report, but this latest request is 4 pages long and
difficult to reformat to look right coming out of
Access. It would be nice if I could just send the word
document to the printer right after the report. Thanks
in advance.
  #2  
Old May 18th, 2004, 10:16 PM
SA
external usenet poster
 
Posts: n/a
Default From Access, print a word doc


Sub PrintWordDoc(strPathAndFileName as String)
On Error resume Next
Dim objWord as Object
Dim objDoc as Object
Const wdPrintAllDocument = 0

Set objWord = CreateObject("Word.Application")
objWord.visible = False
Set objDoc = objWord.Documents.Open(strPathAndFileName)
objWord.ActiveDocument.PrintOut , _
Background:=False, _
Range:=wdPrintAllDocument
objDoc.Close False
Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing

End Sub

That should do it
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg


"RC" wrote in message
...
Does anyone know a slice of VB code that would let me
print a specific word document by clicking a button in
Access? I have a request to print some standard handouts
in addition to every time we print a certain signup
report from Access. (this way all documents are at the
printer together, and we don't have to remember to pull
copies out of the file. Saves a lot of time.) In the
past I have imported the document into Access as a
report, but this latest request is 4 pages long and
difficult to reformat to look right coming out of
Access. It would be nice if I could just send the word
document to the printer right after the report. Thanks
in advance.



  #3  
Old May 19th, 2004, 03:52 AM
RC
external usenet poster
 
Posts: n/a
Default From Access, print a word doc

That works. Thanks. I was getting there, but missed the
bit for opening the document. This really helps.

RC

-----Original Message-----

Sub PrintWordDoc(strPathAndFileName as String)
On Error resume Next
Dim objWord as Object
Dim objDoc as Object
Const wdPrintAllDocument = 0

Set objWord = CreateObject("Word.Application")
objWord.visible = False
Set objDoc = objWord.Documents.Open(strPathAndFileName)
objWord.ActiveDocument.PrintOut , _
Background:=False, _
Range:=wdPrintAllDocument
objDoc.Close False
Set objDoc = Nothing
objWord.Quit
Set objWord = Nothing

End Sub

That should do it
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg


"RC" wrote in

message
...
Does anyone know a slice of VB code that would let me
print a specific word document by clicking a button in
Access? I have a request to print some standard

handouts
in addition to every time we print a certain signup
report from Access. (this way all documents are at the
printer together, and we don't have to remember to pull
copies out of the file. Saves a lot of time.) In the
past I have imported the document into Access as a
report, but this latest request is 4 pages long and
difficult to reformat to look right coming out of
Access. It would be nice if I could just send the word
document to the printer right after the report. Thanks
in advance.



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.