How to delete a drawing symbol from all the sheets in the drawing using VBA?

How to delete a drawing symbol from all the sheets in the drawing using VBA?

shuaib_cad
Advocate Advocate
500 Views
1 Reply
Message 1 of 2

How to delete a drawing symbol from all the sheets in the drawing using VBA?

shuaib_cad
Advocate
Advocate

I want to delete a drawing symbol named "XXX" from all the sheets in the drawing but the symbol is getting deleted from the active sheet only.

 

 

Used the following VBA code:

 

Dim oSymbol As SketchedSymbol

For Each oSymbol In oDoc.ActiveSheet.SketchedSymbols

If oSymbol.Name = "XXX" Then
oSymbol.Delete

 

Please help me with a VBA code to do the operation in all the sheets in the drawing.

 

 

Regards,

Mohammed Shuaib K

0 Likes
Accepted solutions (1)
501 Views
1 Reply
Reply (1)
Message 2 of 2

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @shuaib_cad 

In order to do this you must iterate through each sheet in the drawing document 🙂

Sub DeleteSymbols()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim oSymbol As SketchedSymbol
For Each oSheet In oDoc.Sheets
    For Each oSymbol In oSheet.SketchedSymbols
    If oSymbol.Name = "XXX" Then oSymbol.Delete
    Next
Next
End Sub