Hi Folks,
Can anyone help me write a macro to select a rectangle shape with the pick tool after I manually create it? Normally, when you're done creating a rectangle, the rectangle tool remains selected. I'd like it to automatically return to the Pick tool (with the newly created object selected) after manually creating a rectangle.
Thanks very much,
Jack
Would you be willing to tap the Space Bar? That will toggle from the active tool to the Pick Tool, or from the Pick tool to the most recently active tool.
I've never gotten used to the space bar. In the flow of work, I often have to hit it several times to work. A long time ago - in Coreldraw v3.0, I think - the program always went back to the pick tool after creating a shape. It got burned into my synapses and I've never gotten used to the new way. It's just a nuisance that has bugged me for years. I've written a few scripts in the past, but this one is eluding me.
Jack Coletti said: I've written a few scripts in the past, but this one is eluding me.
This one is more involved, to the extent that you are not just trying to create or modify CorelDRAW content using a macro. Instead, you're trying to have CorelDRAW always watching to see if a Rectangle has been created, and THEN trying to do something using a macro (change the active tool).
You could try putting this code in the ThisMacroStorage section of a VBA project:
Dim WithEvents CurDoc As Document Private Sub GlobalMacroStorage_WindowActivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Doc End Sub Private Sub GlobalMacroStorage_WindowDeactivate(ByVal Doc As Document, ByVal Window As Window) Set CurDoc = Nothing End Sub Private Sub CurDoc_ShapeCreate(ByVal Shape As Shape) If ActiveShape.Type = cdrRectangleShape Then Application.ActiveTool = cdrToolPick End If End Sub
Code that runs automatically based on events should be used with caution!
In that example, I limited it to only Rectangle shapes, but that could be changed to include other specific types of shapes. Or, you could have it NOT apply to only specific types of shapes. Or, you could have it apply to all types of shapes (perform no check at all with respect to shape type).
Oh man - You are my hero!! This has bugged me for so long and I am so grateful for your help. Thank you!!
Hey, I'm glad to know that helped!