Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim myNote As SldWorks.Note
Dim myAnnot As SldWorks.Annotation
Dim SelMgr As SldWorks.SelectionMgr
Dim myView As SldWorks.View
Dim myDwgDoc As SldWorks.DrawingDoc
Dim CurViewPos As Variant
Dim PointPosOnSheet As Variant
Dim mySelData As SldWorks.SelectData
Sub main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set myDwgDoc = swDoc
Set myView = myDwgDoc.ActiveDrawingView
CurViewPos = myView.Position
Set SelMgr = swDoc.SelectionManager
Set mySelData = SelMgr.CreateSelectData
If SelMgr.GetSelectedObjectType3(1, -1) <> 11 Then
MsgBox "Select a sketch point and run macro again"
Exit Sub
End If
'This seemed like the easiest way to get location
'of the point in sheet space
Set myNote = swDoc.InsertNote("DummyText")
If Not myNote Is Nothing Then
myNote.Angle = 0
boolstatus = myNote.SetBalloon(0, 0)
PointPosOnSheet = myNote.GetAttachPos
Set myAnnot = myNote.GetAnnotation
myAnnot.Select3 False, mySelData
swDoc.EditDelete
Else
MsgBox "Failed to create note for some reason"
Exit Sub
End If
CurViewPos(0) = CurViewPos(0) - PointPosOnSheet(0)
CurViewPos(1) = CurViewPos(1) - PointPosOnSheet(1)
myView.Position = CurViewPos
swDoc.ClearSelection
swDoc.WindowRedraw
End Sub