1 Reply Latest reply on Jun 2, 2015 7:39 AM by Leon Wurr

    Macro to replace text does not work with special "symbols" in note?

    Albert Mejia

      Not a code expert but here is a part of what I have. It does work but will not work when the note has "Delta Flag Note Nmber",   "Surface finish Symbol", or "Feature Control Frame"

      in the note. It will completely remove all the text in the note if it does.


      Private Sub cmbRemove_Click()
      Set swApp = _

      Set Part = swApp.ActiveDoc
      Part.Save2 False

      '--------------------Find and Replace Annotations--------------------
      Set swUtil = swApp.GetAddInObject("Utilities.UtilitiesApp")
      Set swUtilFindReplaceAnnotations = swUtil.FindReplaceAnnotations
      longstatus = swUtilFindReplaceAnnotations.InitPMPage()
      #If 0 Then
      #End If
      '--------------------UnBlock Recording------------------
      swUtilFindReplaceAnnotations.FindText = "(" + txtNumberX.Value + ")"
      swUtilFindReplaceAnnotations.ReplaceText = ""
      swUtilFindReplaceAnnotations.AnnotationFilter = gtFraNote
      longstatus = swUtilFindReplaceAnnotations.FindNext()
      longstatus = swUtilFindReplaceAnnotations.Replace()

      '--------------------UnBlock Recording------------------

      'longstatus = swUtilFindReplaceAnnotations.Close()

      End Sub

        • Re: Macro to replace text does not work with special "symbols" in note?
          Leon Wurr

              I believe you're working with compound notes, you should use something in the lines of:


                      If swNote.IsCompoundNote Then

                          nTextCount = swNote.GetTextCount


                          For i = 1 To nTextCount

                              sNoteText = swNote.GetTextAngleAtIndex

                              DoReplaceString sNoteText

                              swNote.SetTextAtIndex i, sNoteText

                          Next i


                          sNoteText = swNote.GetText

                          DoReplaceString sNoteText

                          swNote.SetText sNoteText

                      End If



          2012 api - Change Note Text Example (VBA)

          2012 SOLIDWORKS API Help - Compound Note