PDF printing using VBA

PDF printing using VBA

Anonymous
Not applicable
1,854 Views
5 Replies
Message 1 of 6

PDF printing using VBA

Anonymous
Not applicable

Hi all,

 

I am new to VBA. I need help to write VBA code in AutoCAD'18 to print PDF file which is store stored on my PC, by setting the following parameters of printer,

1. Printer name

2. Orientation 

3. Paper size (A3/A4)

4. Print on both sides of paper (either Flip on long edge or Flip on short edge)

5. Pages to print (All)

Can someone please help me to get the VBA code for above requirement? Your help is highly appreciated.

 

 

1,855 Views
5 Replies
Replies (5)
Message 2 of 6

Ed__Jobe
Mentor
Mentor

This is an old subject. If you search this forum for "plot" or "plotconfig", you should find plenty of code samples.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 6

Anonymous
Not applicable

Hi,

 

I have written the following code, which I expect to open the PDF file and send it to printer. It is opening the PDF file, but printer code is not working. can Someone Please help me?

 

Sub PrintPDFFile()

Dim ObjShell As Object
Dim path As String
Dim DrgPrintMgr As Printer

path = "C:\Users\Desktop\Print\L00G92N-T.pdf"
Set ObjShell = CreateObject("Shell.Application")
ObjShell.Open (path)

With ObjShell
Set DrgPrintMgr = File.PrintManager
With DrgPrintMgr
.Printer = "\\pu3insvns01\PU3INP01"
.AllColorsAsBlack = True
.ColorMode = kPrintGrayScale
'.ScaleMode = kPrintBestFitScale
.PaperSize = kvbPRPSA3
'.PaperSize = [vbPRPSA4]
.PrintRange = kPrintAllSheets
.Orientation = kLandscapeOrientation
.RemoveLineWeights = False
.SubmitPrint
End With
End With

End Sub

0 Likes
Message 4 of 6

Ed__Jobe
Mentor
Mentor

What library does your project reference that has a PrintManage object? You use a File object but don't set an instance of it. When the file opens, what program does it open in? You need to use that program's api (if it has one) to print the file.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 5 of 6

Anonymous
Not applicable

Hi Ed.Jobe

 

When the document open, it opens in the "Adobe Acrobat DC" . Can you please help me with "Adobe Acrobat DC" API's to print PDF file?

0 Likes
Message 6 of 6

Ed__Jobe
Mentor
Mentor

I checked and Reader doesn't have an api. If you bought the pro version it might.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes