Hide Table of Contents

Create Presentation Studio PDF (VBA)

This example shows how to create a SolidWorks Presentation Studio PDF file.

'------------------------------------------
'
'
' Preconditions:
'
' 1. C:\temp folder exists.
' 2. The theme, C:\Program Files\SolidWorks Corp\SolidWorks\data\themes\red\theme.xml, exists.
' 3. Open C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\routing-pipes\fittings\ReducerRoute.sldasm
'    and create a named view called DownView.
' 4. Run the macro.
'
' Postconditions:
' 1. C:\temp\MyPresentation.pdf is created and
'    includes the active, back, trimetric, and DownView
'    views.
' 2. Close the PDF file.
'
' NOTE:  Because this assembly document is used by a
'        SolidWorks tutorial, do not save it when
'        when closing it.
'
'------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim pdfFile As String
Dim themeXML As String
Dim textNamedViewArray(0) As String
Dim textNameArray(2) As String
Dim textArray(2) As String
Dim presentationOpts As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
' Set name of PDF file, presentation theme XML file,
' presentation standard view options, and name of the user-created name view
pdfFile = "C:\temp\MyPresentation.pdf"
themeXML = "C:\Program Files\SolidWorks Corp\SolidWorks\data\themes\red\theme.xml"
' Examine the template's theme.xml
' to determine if textNameArray must be set;
' i.e., each text_area XML element must be have
' a corresponding textNameArray array element
textNameArray(0) = "Title"
textNameArray(1) = "Summary"
textNameArray(2) = "Description"
textArray(0) = "My Presentation"
textArray(1) = "My part"
textArray(2) = "My PDF"
' You must specify swPresentationOpts_Pres and
' any other standard views you want to include
' in your presentation
presentationOpts = (swPresentationOpts_Pres + swPresentationOpts_BackView + swPresentationOpts_TrimetricView)
' User-created named view to include in presentation
textNamedViewArray(0) = "DownView"
' Create presentation
swModelDocExt.CreatePresentation2 pdfFile, themeXML, presentationOpts, textNamedViewArray, textNameArray, textArray
' Deselect component
swModel.ClearSelection2 True
End Sub

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Presentation PDF (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2014 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.