1 Reply Latest reply on Sep 15, 2014 8:51 AM by Jesse Seger

    save as  file is fails?

    Yong Ning

      Use follow code, save file is fails.

       

       

       

       

       

      0.jpg

       

       

      1.jpg

       

       

       

       

       

      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)

               'Stop

               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 "  ************************ "

            'Stop

          Next ii

        Timing T

      End Sub