Skip to main content

Example to format portions of the note text with different formats

This VBA example demonstrates how to insert note into SOLIDWORKS document and format individual lines with different font effects and styles.

Formatted text of the note

Portions of the text can be formatted with \<FONT> instruction. This instruction has 2 attributes

  • effect - can be equal to U (underline) or RU (remove underline)
  • style - can be equal to B (bold), RB (remove bold), I (italic) or RI (remove italic)

All the text after the \<FONT> instruction will be formatted according to the value of effect and style.

INote::GetText methods returns the resolved value of the note. For the note above it will return the following result:

First Line Underline
Second Line Bold
Third Line Italic

INote::PropertyLinkedText property sets or gets the text supporting the \<FONT> instruction. For the note above it will return the following result:

<FONT effect=U>First Line Underline
<FONT style=B effect=RU>Second Line Bold
<FONT style=RB><FONT style=I>Third Line Italic
Dim swApp As SldWorks.SldWorks

Sub main()

Set swApp = Application.SldWorks

Dim swModel As SldWorks.ModelDoc2

Set swModel = swApp.ActiveDoc

Dim swSelMgr As SldWorks.SelectionMgr

Set swSelMgr = swModel.SelectionManager

Dim swNote As SldWorks.Note

Set swNote = swModel.InsertNote("<FONT effect=U>First Line Underline" & vbLf & "<FONT style=B effect=RU>Second Line Bold" & vbLf & "<FONT style=RB><FONT style=I>Third Line Italic")

Debug.Print swNote.GetText()
Debug.Print swNote.PropertyLinkedText

End Sub