Hi everyone,
I'm at the moment creating a One-Click-Callout macro in Designer X6 tailored to our specific needs.
While I've finally managed to get the macro up and running fine, I still encounter two issues, that should just not happen.
The project:
I've got a user form that allows to specify several parameters (like numbering direction) and provides some quality of life functionality (like placing pre-rotated guidelines).
The user form is non-modal and allows for changing stuff on the fly.
The callouts (CalloutShape class used) are drawn to guide lines, spaced out properly and (if ticked) numbered correctly on-the-fly.
The document uses layers (1 for the bitmap, 1 for the callouts, 1 for the guide lines).
The strange stuff I encountered:
1. I'm using the GetUserClick method with snap enabled to capture the origins for the callouts. Works perfectly for the most part. But if the layer with the underlying bitmap is editable, I randomly get snaps to the bitmap snap points - even when they're "miles" away from the original click coordinates. I couldn't find any reproducible way how this occurs and for the moment, I've worked around it by disabling editing of the bitmap layer.
Code:
EventsEnabled = False bSnap = True bClick = False ActivePage.Layers("Abbildung").Editable = False While Not bClick bClick = ActiveDocument.GetUserClick(xClick, yClick, lModKey, 100, bSnap, cdrCursorSmallcrosshair) If Not bClick Then 'do stuff End If Wend
EventsEnabled = False bSnap = True bClick = False ActivePage.Layers("Abbildung").Editable = False
2. When I start up Designer, the very first callout I place goes to the (0,0) document coordinates - starting coordinates AND endpoint coordinates. I did check the click coordinates returned, which were just as they should be. So are the calculated variables I use for placement. It is a minor annoyance, as it really only happens once - but it still annoys me, since the rest of the code is working great.
'some more nifty code up front startNo = oneClickCallouts.startNumber.Value Set coAll = getAllCalloutData() If noNeighbor Then Set ocCallout = ActivePage.Layers("Callouts").CreateCustomShape("Callout", CStr(startNo + coAll.Count), 0, 0.1, Array(xSafe, ySafe), _ Array(xDes, yDes), 0.03, Nothing, 100, 0) Else If orgClick.clickVector = "up" Or orgClick.clickVector = "down" Then Set ocCallout = ActivePage.Layers("Callouts").CreateCustomShape("Callout", CStr(startNo + coAll.Count), 0, 0.1, Array(xSafe, ySafe), _ Array(xNew, yOrg), Array(xNew, yNew), 0.03, Nothing, 100, 0) Else Set ocCallout = ActivePage.Layers("Callouts").CreateCustomShape("Callout", CStr(startNo + coAll.Count), 0, 0.1, Array(xSafe, ySafe), _ Array(xOrg, yNew), Array(xNew, yNew), 0.03, Nothing, 100, 0) End If
Any ideas what could be wrong are highly appreciated.