Hide Table of Contents

Set Note Name Example (VBA)

This example shows how to set the name of a selected note. You can combine this code with a dialog that prompts the user for a desired name, or you can programmatically determine the new note name.

 

'------------------------------------------------------------------

Sub SetNoteName( newNoteName As String )

 

' Define variable used to hold the SldWorks object

Dim swApp As Object    

 

' Define variable used to hold the ModelDoc object

Dim Model As Object    

 

' Define variable used to hold the SelectionMgr object

Dim SelMgr As Object   

Dim note As Object

Dim checkNoteName As String

 

Const swSelNOTES = 15   

Const swDocDRAWING = 3

 

' Attach to or open SOLIDWORKS session

Set swApp = CreateObject("SldWorks.Application") 

' Grab the current document

Set Model = swApp.ActiveDoc     

 

' Verify that the document is a drawing

If (Model Is Nothing) Or (Model.GetType <> swDocDRAWING) Then

Exit Sub

End If

 

Set SelMgr = Model.SelectionManager

 

' Make sure a selection exists

If (SelMgr.GetSelectedObjectCount = 0) Then  

swApp.SendMsgToUser "Select a Note first..."

 

Else 

' If selected object is a note

If (SelMgr.GetSelectedObjectType(1) = 15) Then 

' Get the Note object from the selection list

Set note = SelMgr.GetSelectedObject2(1)  

' Use the Note object to change the note name

res = note.SetName (newNoteName)   

checkNoteName = note.GetName

 

' If note name does not match

If (checkNoteName <> newNoteName) Then  

swApp.SendMsgToUser "Error changing note name."  

End If

 

End If

 

End If

 

End Sub

 

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Set Note Name Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2021 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.