×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB/SolidWorks printing to distiller

VB/SolidWorks printing to distiller

VB/SolidWorks printing to distiller

(OP)
Does anyone have a nice example of printing a SolidWorks drawing to Adobe Acrobat distiller?

How about saving "ImAdrawing.SLDDRW" to the desktop?

Thanks,
Josh

RE: VB/SolidWorks printing to distiller

(OP)
I'M HAVING PROBLEMS GETTING EITHER ACROBAT DISTILLER OR ACROBAT PDFWRITER TO PRINT PDF FILES TO A SPECIFIC LOCATION OR PRINT AT ALL USING VB TO DRIVE SOLIDWORKS.  NO PROBLEMS WHEN I PRINT TO EITHER THROUGH THE SOLIDWORKS TOOLBAR.  I CAN USE VB TO MAKE SOLIDWORKS PRINT TO ANY OTHER OF THE PRINTERS, BUT NOT PDF TO FILE.  IF ANYONE HAS A GOOD EXAMPLE I WOULD GREATLY APPRECIATE IT.  THE EXAMPLE IN THE SOLIDWORKS API IS NOT WORKING FOR SOME REASON.  HOPEFULLY I'M JUST MISSING SOMETHING SIMPLE.

THANKS
JOSH

RE: VB/SolidWorks printing to distiller

(OP)

Here's the code to get SolidWorks to make a PDF file in the same location as SolidWorks drawing if anyone is interested.

Put this in a module and call from VB app:

GENERAL DECLARATIONS
Option Explicit
Const vbPRORPortrait                    As Long = 1
Const vbPRORLandscape                   As Long = 2
Const vbPRPSLetter                      As Long = 1
Const vbPRPSLetterSmall                 As Long = 2
Const vbPRPSTabloid                     As Long = 3
Const vbPRPSLedger                      As Long = 4
Const vbPRPSLegal                       As Long = 5
Const vbPRPSStatement                   As Long = 6
Const vbPRPSExecutive                   As Long = 7
Const vbPRPSA3                          As Long = 8
Const vbPRPSA4                          As Long = 9
Const vbPRPSA4Small                     As Long = 10
Const vbPRPSA5                          As Long = 11
Const vbPRPSB4                          As Long = 12
Const vbPRPSB5                          As Long = 13
Const vbPRPSFolio                       As Long = 14
Const vbPRPSQuarto                      As Long = 15
Const vbPRPS1_H14                       As Long = 16
Const vbPRPS11x17                       As Long = 17
Const vbPRPSNote                        As Long = 18
Const vbPRPSEnv9                        As Long = 19
Const vbPRPSEnv10                       As Long = 20
Const vbPRPSEnv11                       As Long = 21
Const vbPRPSEnv12                       As Long = 22
Const vbPRPSEnv14                       As Long = 23
Const vbPRPSCSheet                      As Long = 24
Const vbPRPSDSheet                      As Long = 25
Const vbPRPSESheet                      As Long = 26
Const vbPRPSEnvDL                       As Long = 27
Const vbPRPSEnvC3                       As Long = 29
Const vbPRPSEnvC4                       As Long = 30
Const vbPRPSEnvC5                       As Long = 28
Const vbPRPSEnvC6                       As Long = 31
Const vbPRPSEnvC65                      As Long = 32
Const vbPRPSEnvB4                       As Long = 33
Const vbPRPSEnvB5                       As Long = 34
Const vbPRPSEnvB6                       As Long = 35
Const vbPRPSEnvItaly                    As Long = 36
Const vbPRPSEnvMonarch                  As Long = 37
Const vbPRPSEnvPersonal                 As Long = 38
Const vbPRPSFanfoldUS                   As Long = 39
Const vbPRPSFanfoldStdGerman            As Long = 40
Const vbPRPSFanfoldLglGerman            As Long = 41
Const vbPRPSUser                        As Long = 256
' Defined in swconst.bas
Const swPrintPaperSize                  As Long = 0
Const swPrintOrientation                As Long = 1
Const SWPrinter     As String = "Acrobat PDFWriter"



Sub PDF()
    Dim swApp100                As Object 'SldWorks.SldWorks
    Dim swModel100              As Object 'SldWorks.ModelDoc2
    Dim swDrwDoc                As Object 'SldWorks.DrawingDoc
    Dim swSheet                 As Object 'SldWorks.sheet
    Dim NumSheet                As Long
    Dim PathName                As String
    Dim PrintFileName           As String
    Dim SheetName               As String
    Dim Errors                  As Long
    Dim i                       As Long
    
    Set swApp100 = CreateObject("SldWorks.Application")
    Set swModel100 = swApp100.ActiveDoc
    Set swDrwDoc = swModel100
    
    ' strip off SolidWorks file extension (.sld???)
    PathName = swModel100.GetPathName
    PathName = Left(PathName, Len(PathName) - 7)
        
    'go back to the first sheet
    NumSheet = swDrwDoc.GetSheetCount
    For i = 0 To NumSheet - 1
        swDrwDoc.SheetPrevious
    Next i
    
    
    For i = 0 To NumSheet - 1
        ' generate print filename based on sheet number
        PrintFileName = PathName + "_Sheet-" + Trim(Str(i))
        swDrwDoc.ForceRebuild
        swModel100.PrintOut2 i + 1, i + 1, 1, False, SWPrinter, 0#, True, PrintFileName
        swDrwDoc.SheetNext
    Next i
    
    Set swDrwDoc = Nothing

End Sub



Thanks,

Josh

RE: VB/SolidWorks printing to distiller

(OP)
I forgot to mention that you have to have Adobe Acrobat 5.0 and not just Adobe Reader to print to either the Adobe Distiller(for more detail)  or Adobe PDFWriter(for mainly text documents).

Thanks,

Josh

RE: VB/SolidWorks printing to distiller

Excellent solution!

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: VB/SolidWorks printing to distiller

(OP)
Thanks dsi

Josh

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources