I need Help. I have been researching and Cannot Figure out how to produce an attribute I want to add to my Macro I've been working on.
I am looking for a Macro or Code I can run that will make a selection of each (or all) of these 3 Options. Count how many "corners, sides, or middles" there are for each and display the value in a Msgbox for me.
Example: Pretend I pushed a command button and it counted these for me and displayed values in a msgbox!
1. Corners (red) = 30
2. Sides (green) = 10
3. Middle (blue) = 20
or
I click command button - it counts all three sides and displays each in text box...
1. Corners (red) = 30 (shows in textbox1)
2. Sides (green) = 10 (shows in textbox2)
3. Middle (blue) = 20 (shows in textbox1)
My goals is to eventually "search all corners,sides, middles and have that value automatically show in my ' textbox" so i dont have to type it in! But right now the prompt message will suffice.
Here is my macro I've been working on. It works fairly good so far!! I just need a little help with one of the two options above!
Note: I do have the "find" option. But because my templates are grouped and easy to move around that way, I'd like to keep them grouped. I dont want to have to ungroup everything on the page to get a count of all my "reds" then all my 'blues" then my greens and be forced to group all my sides back together. I created a video but i seriously cannot get the size down... So im left w/print screens.
My Macro Generates the Columns already. That works fine. I just want an easier way to count the each of the three tiles on the page.
Depending on what exact color your shapes are you may need to look in help on how to change this, but you can try this:
Count = ActivePage.Shapes.FindShapes(, , , "@fill.color='red'").Count
Or, simply give your shapes descriptive names, like "RedTile" and do:
Count = ActivePage.Shapes.FindShapes("RedTile").Count
Just because CQL rocks, I have to toss a few options out there.
Sub FindWithCQL() 'Find all shapes with fill named red Count = ActivePage.Shapes.FindShapes(Query:="@fill.color='red'").Count 'Find all shapes with cmyk red fill Count = ActivePage.Shapes.FindShapes(Query:="@fill.color = cmyk(0,100,100,0)").Count 'Find all shapes with rgb red fill Count = ActivePage.Shapes.FindShapes(Query:="@fill.color = rgb(255,0,0)").Count 'Find all shapes with rgb or cmyk red fill Count = ActivePage.Shapes.FindShapes(Query:="@fill.color = rgb(255,0,0) or @fill.color = cmyk(0,100,100,0)").Count 'You can also write the above like this Count = ActivePage.Shapes.FindShapes(Query:="@fill[.color = rgb(255,0,0) or .color = cmyk(0,100,100,0)]").Count 'Find only rectangles filled with red Count = ActivePage.Shapes.FindShapes(Query:="@fill.color='red' and @type='rectangle'").Count End Sub
-Shelby
Okay, so it took me two seconds to accomplish what I needed! Thanks Shelby. Here is the code I used. I first tested it on a userform1 before adding to my macro to see if it would work.
1. Created a commandbutton1
2. create a textbox1
Private Sub CommandButton1_Click()Dim redCorner As ShapeRangeSet redCorner = ActivePage.Shapes.FindShapes(Query:="@fill.color = rgb(255,20,60)")TextBox1 = redCorner.CountEnd Sub
And it fills in the textbox1 for me with the value automatically so i can generate my little table :) Super excited :)
You can see video here if you want.
Modular Tiles Macro from chieri thompson on Vimeo.