AnsweredAssumed Answered

Macro to change notes to document font

Question asked by Alice Caspari on Aug 13, 2015
Latest reply on Nov 30, 2018 by perry leets

I have a macro to traverse each drawing view and change the notes in that view to use the document font.

It works but it changes the fonts in the sheet format/ titleblock as well which I don't want it to do.

Any ideas on where I went wrong?



Option Explicit

' Select all annotations and set to use Document Font - 08/12/15 by Casparia

    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swView As SldWorks.View

    Dim swTextFormat As SldWorks.textFormat

    Dim i As Long
    Dim j As Long
    Dim annotations As Variant  
    Dim notes As SldWorks.annotation  
    Dim count As Long  
    Dim bool As Boolean


  Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel

    ' Iterate through all the views on the drawing to find annotations

    Set swView = swDraw.GetFirstView

    Do While Not swView Is Nothing
        count = swView.GetAnnotationCount
    ' Iterate through all the annotations in each drawing view that has them and set to use document font

    If count > 0 Then

            annotations = swView.GetAnnotations

            For j = 0 To UBound(annotations)

                Set notes = annotations(j)
                bool = notes.SetTextFormat(i, True, swTextFormat)

            Next j

        End If

        Set swView = swView.GetNextView


End Sub