View Single Post
  #1  
Old 01-11-2008, 02:37
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Post Joe's toolbox macro (in progress)

Hello! First post here.

Started trying to make my own VBA macros just yesterday to ease a specific task (importing a bunch of CAD drawings, resizing all of them by a percentage, etc) and have already snowballed out of control by making a crazy toolbox:



Yes, it's something only a father would love

Anyways, a question: I'd like to select a bunch of things on a page and then just press a button like "Top Left" to set the Alignment of Text (You can see this in the sort-of Joystick like thing next to the "Insert text" button). My code is such:

Code:
For Each Current In ActiveSelectionRange
     Current.Text.Frame.VerticalAlignment = cdrTopJustify
     Current.Text.Selection.Alignment = cdrLeftAlignment
Next Current
And it works ok as long as no non-text shapes are selected. What would be nice, though, would be to make it work on anything - if there is text, adjust, if it's a shape, ignore.

I realize some check is needed, but really can't find how to do it. This forum has already helped with the Alignment settings, hopefully this can be solved as well.

Thanks!

Edit: D'oh! With all this typed up I click "New posts" and bam! This one already has the necessary check visible:

Code:
For Each Current In ActiveSelectionRange
  If Current.Type = cdrTextShape Then
    Current.Text.Frame.VerticalAlignment = cdrTopJustify
    Current.Text.Selection.Alignment = cdrLeftAlignment
  End If
Next Current
Btw, is there a reliable code formatter/beautifier for VBA, preferably online?

Last edited by Joe; 06-11-2008 at 05:53.
Reply With Quote