1 Reply Latest reply on Jul 27, 2018 11:34 AM by Fifi Riri

    How can export the cartouches field with a macro

    Luca Maestrini

      Goodmorning,

      I want to export same cartouches fileds in a file, for example a txt, because i want to control these.

      In the cartouches there are many fields and I, in the drawing 2D, can see them in sheet format, cartouches filed. The text field are in a indented list that report the relative value like this:

      Can I export them in a file with a macro?

       

      Thank

        • Re: How can export the cartouches field with a macro
          Fifi Riri

          Hello, try this.

          It will create a text file in C:\

           

          Option Explicit

          Sub main()

          Dim swApp As SldWorks.SldWorks

          Dim swDraw As SldWorks.DrawingDoc

          Dim swView As SldWorks.View

          Dim swNote As SldWorks.Note

          Set swApp = Application.SldWorks

          Set swDraw = swApp.ActiveDoc

          Set swView = swDraw.GetFirstView

          Set swNote = swView.GetFirstNote

          Do While Not swNote Is Nothing

            Debug.Print swNote.GetName

            Debug.Print "  " & swNote.PropertyLinkedText

            'Debug.Print "  " & swNote.GetText

            Debug.Print

            WriteFile swNote.GetName & " :  " & swNote.PropertyLinkedText & vbCrLf

            Set swNote = swNote.GetNext

          Loop

          End Sub

           

          Sub WriteFile(logSTR As String)

            Dim My_filenumber As Integer

            My_filenumber = FreeFile

            Open "C:\MyNotes.txt" For Append As #My_filenumber

            Print #My_filenumber, logSTR

            Close #My_filenumber

          End Sub

           

          To export in a Excel file change those lines:

          ...

            WriteFile swNote.GetName & "," & swNote.PropertyLinkedText

          ...

            Open "C:\MyNotes.CSV" For Append As #My_filenumber

          ...