Hide Table of Contents

Change Set Up of Drawing Sheet Example (VBA)

This example shows how to change the set up of an existing open drawing sheet by changing its paper size and template.

 

'---------------------------------

'

' Preconditions: Drawing with a drawing sheet is open.

'

' Postconditions: Template of open sheet is changed.

'

'----------------------------------

Option Explicit

Public Enum swDwgPaperSizes_e

    swDwgPaperAsize = 0

    swDwgPaperAsizeVertical = 1

    swDwgPaperBsize = 2

    swDwgPaperCsize = 3

    swDwgPaperDsize = 4

    swDwgPaperEsize = 5

    swDwgPaperA4size = 6

    swDwgPaperA4sizeVertical = 7

    swDwgPaperA3size = 8

    swDwgPaperA2size = 9

    swDwgPaperA1size = 10

    swDwgPaperA0size = 11

    swDwgPapersUserDefined = 12

End Enum

Public Enum swDwgTemplates_e

    swDwgTemplateAsize = 0

    swDwgTemplateAsizeVertical = 1

    swDwgTemplateBsize = 2

    swDwgTemplateCsize = 3

    swDwgTemplateDsize = 4

    swDwgTemplateEsize = 5

    swDwgTemplateA4size = 6

    swDwgTemplateA4sizeVertical = 7

    swDwgTemplateA3size = 8

    swDwgTemplateA2size = 9

    swDwgTemplateA1size = 10

    swDwgTemplateA0size = 11

    swDwgTemplateCustom = 12

    swDwgTemplateNone = 13

End Enum

Sub main()

    Const sTemplatePath As String = "c:\Program Files\SOLIDWORKS\data\b-landscape.slddrt"

    

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swDraw                      As SldWorks.DrawingDoc

    Dim swSheet                     As SldWorks.Sheet

    Dim bRet                        As Boolean

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swDraw = swModel

    Set swSheet = swDraw.GetCurrentSheet

    

    bRet = swDraw.SetupSheet4( _

                swSheet.GetName, _

                swDwgPaperBsize, _

                swDwgTemplateBsize, _

                1#, 1#, _

                False, _

                "", _

                0#, 0#, _

                "")

    swModel.ForceRebuild3 (False)

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:   Set Up Drawing Sheet Example (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) 2015 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.