Force Printer to show word paper type (1 Viewer)

stu_c

Registered User.
Local time
Today, 04:15
Joined
Sep 20, 2007
Messages
492
Hi all
I have some VBA code that opens up a word document, copies data from the access form into the word document then automatically prints.
the word document is an envelope template.

for some reason the printer doesn't automatically recognize the paper type is an envelope, is there a way to force the printer to think this within the VBA code?

Code:
Public Function FUNC_CreateC5Envelope()
'FIND WORD FILE
    Dim oWd  As Object 'Word.Application
    Dim oDoc As Object 'Word.Document
    Dim bm   As Object 'Word.Bookmark
    
    'Set oWd = New Word.Application
    Set oWd = CreateObject("Word.Application")
    Set oDoc = oWd.Documents.Add(CurrentProject.Path & "\TemplateFiles\C5EnvelopeTemplate.docx")


***********FIELD INPUTS HERE ******

'PRINT OUT
   oDoc.PrintOut

'Close but dont save
  oDoc.Close False
  oWd.Quit
  Set oDoc = Nothing
  Set oWd = Nothing
  'oWd.Visible = True

End Function
 
Tom shows you how to set the parameters on the document side of the equation. There is also a way to determine the printer's settings.

First, you can find the default printer this way:


You can see other printers this way (as a collection of printer objects) so that you can get a printer name if you have a preference:


The above links let you find the printer object. Once you have it, you can see the printer's properties - and set some of them.


If you look at the printer.papersize property, that is actually an encoded numeric selector for a variety of sizes. Several envelope sizes are in the list.


This plus Tom's information should be enough for you to determine and assert whatever you need on BOTH sides of the printer/document pair, with a warning that not all printers support all possible paper size constants. Therefore when trying to assert a paper size or other property within VBA, be prepared to test for or trap errors.

Note also that sometimes an office printer is set up as restricted in what you can select. For instance, a particular printer might be locked down to only print "Letter" (8 1/2 x 11) format. That would be a matter between you and the IT staff. For an ordinary network-enabled printer that does not have restrictions, the above should be enough.
 
Hi all
It seems that the error shows on the printer because the printer of this when I click on printer properties within file > Print.
the actual page page is set to C5.

If I just click print the error shows, but if I click Printer properties > OK then print then its fine. I am guessing I need to somehow default in VBA to set the media type to Envelope any suggestions?
 

Attachments

  • Untitled.png
    Untitled.png
    42 KB · Views: 56

Users who are viewing this thread

Back
Top Bottom