AnsweredAssumed Answered

Macro for Deleting Item off Current Drawing Sheet

Question asked by Taylor Duran on Nov 21, 2017

I am trying to create a macro that will delete a note off of a current drawing sheet format.

The note is standard on the template but is only needed on certain drawings.

When I recorded the macro it worked fine but would only delete the note from the single sheet in the drawing and wouldn't work on any other.


I think I am am close but am having trouble specifying the current sheet. This is the code I have so far. Any help & suggestions would be greatly appreciated


Sub main()



Dim swApp As Object



Dim Part As Object

Dim swModel As SldWorks.ModelDoc2

Dim swConfig As SldWorks.Configuration

Dim swDrawingDoc As SldWorks.DrawingDoc

Dim swSheet As SldWorks.Sheet

Dim nDocType As Long

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long





Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swDrawingDoc = swModel

Set swSheet = swDrawingDoc.GetCurrentSheet



Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("& swSheet.GetName() &", "SHEET", 8.88251268656716E-02, 0.249583432835821, 0, False, 0, Nothing, 0)



Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("DetailItem159@ & swSheet.GetSheetFormatName() & ", "NOTE", 0.390947932206707, 0.230293898698196, 0, False, 0, Nothing, 0)


boolstatus = Part.Extension.SelectByID2(" & swSheet.GetSheetFormatName() & ", "SHEET", 0.284276326189945, 0.223110625565754, 0, False, 0, Nothing, 0)



Part.ClearSelection2 True



' Zoom To Fit


End Sub



Thanks in advance!