MACRO LIBRARY

Search and replace title block notes

Free public access. No account or subscription required.

Files

Search and replace title block notes

Code

'Preconditions: drawing is open
'Results: any drawing note containing the search string has its text modified to contain _
    the replace string
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Const strSearch As String = "Box_profile_1-RevB"
Const strReplace As String = "Box_profile_1"
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swNote As SldWorks.Note
Dim swView As SldWorks.View
Dim vNotes As Variant
Dim i As Integer
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swView = swDraw.GetFirstView
    vNotes = swView.GetNotes
    For i = 0 To UBound(vNotes)
        Set swNote = vNotes(i)
        If InStr(1, swNote.GetText, strSearch) <> 0 Then
            swNote.SetText strReplace
        End If
    Next i
End Sub