AnsweredAssumed Answered

Looping Through Reference Configurations and Saving Each

Question asked by Weston Schiltz on May 30, 2019

Hello, I need help with looping through reference configurations on a drawing file that will save each configuration as an ai file then end. I started recording a macro then modifying it. The configurations do not change and I am having a hard time finding a good way to create the loop. Right now refcon is giving me an object error and I have switched it to an object and integer and I'm still getting an error. 


Here is what I have. 


Sub SwitchandSave()

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim i As Integer
Dim refcon As Variant

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set refcon = Part.ReferencedConfiguration

   For i = 0 To UBound(refcon())

      longstatus = Part.SaveAs3("folder location" & refcon(i) & ".ai", 0, 2)

      boolstatus = Part.ActivateView("Drawing View1")
      boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 2.86588323167284E-02,       0.042008663583815, 0, False, 0, Nothing, 0)
      boolstatus = Part.ChangeRefConfigurationOfFlatPatternView("folder location", "refereance configuration name")      

   Next i

End Sub