AnsweredAssumed Answered

Macro for saving file as configuration name?

Question asked by John García on Jul 19, 2016
Latest reply on Aug 15, 2018 by Dan Pihlaja

I am currently making changes to a model with 100+ configurations and i'm writing a macro so it can be more time consuming. What i've got so far is a macro that rebuilds all the sheets in a drawing then goes back to the first sheet and opens up the save as box. I would like to make it so it saves the file in a specific location as the configuration name. Here is what i have so far:

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

'Rebuilds all sheets and saves document as the current configuration name

 

Sub main()

 

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

 

 

    Dim SheetNames              As Variant

    Dim Part                    As Object

    Dim SheetCount              As Integer

    Dim i                       As Integer

    Dim boolstatus              As Boolean

    Dim longstatus As Long, longwarnings As Long

    Dim IncludeUnsaved          As Boolean

    Dim bool                    As Boolean

   

   

    'get all sheet names

    SheetNames = swModel.GetSheetNames

   

    'get total number of sheets

    SheetCount = swModel.GetSheetCount

   

    'Rebuilds all sheets

    For i = 0 To SheetCount - 1

        retval = swModel.ActivateSheet(SheetNames(i))

        swModel.GraphicsRedraw2

        swModel.ViewZoomtofit2

 

 

                retval = swModel.ForceRebuild3(False)

 

 

        Debug.Print (i + 1)

   

    Next

    Set swApp = _

Application.SldWorks

 

 

Set Part = swApp.ActiveDoc

 

 

    Dim ActiveView              As Object

    Dim PartName                As String

    Dim value                   As Boolean

    Dim FileName                As String

   

    IncludeUnsaved = True

Set ActiveView = Nothing

Part.ClearSelection2 True

 

 

'Goes to Sheet 1

boolstatus = Part.ActivateSheet("Drawing")

 

 

'Saves document as

swModel.Extension.RunCommand swCommands_SaveAs, Empty

 

End Sub

Outcomes