AnsweredAssumed Answered

save as  file is fails?

Question asked by Yong Ning on Sep 13, 2014
Latest reply on Sep 15, 2014 by Jesse Seger

Use follow code, save file is fails.















Private Sub ShowConfigurationInFeature()

  Dim Str, T: T = Timer

  Dim Xls As Excel.Application, Wk As Workbook

  Dim Sht As Worksheet, Rng As Range, oRng As Range

    Set Xls = GetObject(, "Excel.Application")

    Set Wk = Xls.Workbooks("BomTank.Xls")

    Set Sht = Wk.Sheets("SldAsmName")

    With Sht

      Set Rng = .Range(.Cells(3, 3), .Cells(.Range("C65536").End(3).Row, 3))

    End With

  Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, oSwModel As ModelDoc2

    Set SwApp = GetObject(, "SldWorks.Application")

    Set SwModel = SwApp.ActiveDoc

  Dim SwConf As Configuration, ConfArr, SwComp As Component2

    ConfArr = SwModel.GetConfigurationNames

  Dim SwFeat As Feature


    For ii = 1 To UBound(ConfArr)


      SwModel.ShowConfiguration ConfArr(ii)


      For kk = 1 To Rng.Rows.Count

         Str = Rng(kk, 1)


         Set SwFeat = SwModel.FeatureByName(Str)

         Debug.Print ConfArr(ii), SwFeat.Name, SwFeat.GetTypeName

         Set SwComp = SwFeat.GetSpecificFeature


         Set oSwModel = SwComp.GetModelDoc

         If Not oSwModel Is Nothing Then

           oSwModel.ShowConfiguration2 SwComp.ReferencedConfiguration

         End If

      Next kk


      Debug.Print "  ************************ "


    Next ii

  Timing T

End Sub