AnsweredAssumed Answered

GetPrintSpecification causing Solidworks to Crash

Question asked by Peter Kennedy on Apr 13, 2017
Latest reply on Apr 13, 2017 by Peter Kennedy

I have issues with the code below when I do the following steps, (Using Solidworks 2015 SP5):


1. Open Drawing

2. Run Macro

3. Close Drawing

4. Close Solidworks

5. Solidworks Crashes


However if I:


1. Open Drawing

2. Run Macro

3. Close Solidworks

4. Closes without Crashing


With this code I'm just trying to get the total number of pages in the drawing. See Code Below:


Option Explicit


Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2



Dim swModelDocExt As SldWorks.ModelDocExtension

Dim printSpec As SldWorks.PrintSpecification


Dim TotalNumPages As Integer


Sub main()

    'Setting the required programs and Documents

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc


    Set swModelDocExt = swModel.Extension


    'Set the printing specs

    Set printSpec = swModelDocExt.GetPrintSpecification


    'Get total number of sheets

    TotalNumPages = printSpec.SheetCount


    MsgBox (TotalNumPages)


End Sub


Message was edited by: Peter Kennedy - Isolated the issue even further.