Hey guys.
This should be quite simple for you macro masters, but I just can't find the magic words, and I've tried. My initial idea was to run a macro which selects everything in a designated area, then pauses to wait for a /user click/ , in which time I can look down at the Object Information to see how many shapes in that area are selected, and upon the click I would activate the text field to make it ready for me to type in that number. I did get that far, although it only selects the text field and does not make it actually ready for typing. Then I imagined that there is probably a way to program the whole process.
How can I have VBA get that object count, find that text field (in this case its the "Count#" at the top left) and put that number into the field? Here is an image of what I'm talking about:
Here is the current code:
Sub PanelCount()Dim ss As Shape, x1 As Double, y1 As Double, shift As LongSet ss = ActivePage.SelectShapesFromRectangle(0, 0, 21, 17.5, True)ActivePage.Shapes.FindShapes(query:="@height = {18 in} and @width = {24 in}").RemoveFromSelectionretvall = ActiveDocument.GetUserClick(x1, y1, shift, 10, True, cdrCursorPickOvertarget)ActivePage.Shapes.FindShapes(query:="@height = {1.028 in} and @width = {4.39 in}").CreateSelectionEnd Sub
As you can see, it also selects and then removes the blue rectangles which are my space limit, as the page size must remain 24x18, but I can only use 21x17.5 of that space.
So, how can this be adjusted to use that number of circles found by the SelectShapesFromRectangle and change that text which reads "Count#" to be that number of circles, in this case?
.cdr file here: drive.google.com/open
try code below
Sub PanelCount()Dim ss As ShapeActiveDocument.BeginCommandGroup ("number")Set ss = ActivePage.SelectShapesFromRectangle(0, 0, 21, 17.5, True)ActivePage.Shapes.FindShapes(query:="@height = {18 in} and @width = {24 in}").RemoveFromSelectionmynum = ActiveSelection.Shapes.CountActivePage.TextReplace "#", " " & mynum, True, FalseActiveDocument.EndCommandGroupEnd Sub
Beautiful! That is really awesome, Mek.
Shapes.Count
.TextReplace
NICE. I make around 50 panels like this in a day (all different shapes, circle was just to test). I typically had to select all the shapes by click/drag around them, look at the count on the bottom left and type that number in the "Count#" field over 200 times every week. Now I can just click a button to put that number there! Big thanks, Mek.
Welcome to the one click solultion world!