OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-11-2008, 03: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 06:53.
Reply With Quote
  #2  
Old 01-11-2008, 14:29
Lev
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Joe View Post
Btw, is there a reliable code formatter/beautifier for VBA, preferably online?
I use free Smart Indenter VBA Add-in.
Reply With Quote
  #3  
Old 01-11-2008, 15:47
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Now that looks rather nice, thanks!

And another question has popped up, this one may be a little weird. I would like to select a bunch of complex shapes and simple rectangles. We can assume that every complex shape resides within the rectangle. The task would be to somehow find the shape and its rectangle and then align the shape to the rectangle. I can handle the alignment, finding the rectangle "under" is what seems damn hard.

Any ideas?
Reply With Quote
  #4  
Old 01-11-2008, 20:26
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Find

Just name the shape and find it by its name.
Code:
Set s = ActivePage.FindShape(Name:="MyShapeName")
If you are sure all the other shapes are inside the shape you just found then select them from the bounding boxes of this shape.
Code:
Sub MySelection()
    Dim s As Shape, sFound As Shape
    Dim x As Double, y As Double, w As Double, h As Double
    
    ActiveDocument.ReferencePoint = cdrBottomLeft
    Set s = ActivePage.FindShape(Name:="MyShapeName")
    
    s.GetPosition x, y
    s.GetSize w, h

    Set sFound = ActivePage.SelectShapesFromRectangle(x, y, x + w, y + h, False)
End Sub
Best of luck,
-Shelby
Reply With Quote
  #5  
Old 02-11-2008, 03:38
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Thanks! Noticed that I wasn't clear enough when defining the task as each complex shape would have its own rectangle. But that's ok, found a way to overcome this in a way and this reply helps with another idea I have been having.

And with that another question - I'm trying to implement a selection buffer of sorts - say, select your shapes, click the button and it marks them. Then later you just click another button and all your special shapes get selected. When you decide to create a new selection group or click a, say "Remove selection group" button it would remove all the shapes from the selection ring.

The approach I had in mind was going through the given shapes and adding a tag of sorts, say "Sel1" followed by the shape name so that the tag can be removed later. And then selecting the shapes based on their tags.

But then doing something like CurrentShape.Name = "Tag1 " & CurrentShape.Name only produces "Tag1" as the name of the shape.

Any ideas about this?

And on another note couldn't get the nice looking code identer to work - on CorelDraw X4 and Windows Vista no matter what. Any other suggestions? (Surprisingly google helps very little with this).

Edit: Gonna add a pic here to illustrate the selection idea, this should explain it better:


Last edited by Joe; 02-11-2008 at 04:21.
Reply With Quote
  #6  
Old 02-11-2008, 03:58
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Shape.Properties

Instead of storing your tag in the name, try using Shape.Properties. Also Alex has already written something very similar to this, you might want to check it out.

Oberon Selection Manager

Best of luck,

-Shelby
Reply With Quote
  #7  
Old 02-11-2008, 04:38
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Thanks for the lead, gonna check both out.

I realize that there will be several macros which have similar or the same functionality, but would like to put everything that's useful in one panel that can just hang around there and ease all these things which need to be done so often (of course these things differ depending on your approach, hence Joe's toolbox )

So far it has already really made life easier, and learning VBA is pretty fun so it's all good.
Reply With Quote
  #8  
Old 03-11-2008, 01:50
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Yet another possibly stupid question - would like to implement such a thing: You have a selection, press a button and only the text shapes (or vice versa) within that selection get selected. Tried some things, but no cigar. It's a shame that something like:

Code:
ActivePage.FindShapes(Type:=cdrTextShape).AddToSelection
Isn't available as, say:

Code:
ActiveSelectionRange.FindShapes(Type:=cdrTextShape).AddToSelection
Any ideas on how to best approach this?

And another one - For example there is a shape, a rectangle is drawn around it and then I'd like to group them together. Always use something like:

Code:
For Each Current In ActiveSelectionRange
    'My Code
Next Current
So a Rectangle is drawn, then there's a Current.Move or align or some such action. And after that grouping them would be great.

And sounds like if something decent comes out of this I'll have to give half the credit to Shelby
Reply With Quote
  #9  
Old 03-11-2008, 02:49
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Selection

You almost have it, try:
Code:
ActiveSelectionRange.Shapes.FindShapes(Type:=cdrTextShape).CreateSelection
Best of luck,

-Shelby
Reply With Quote
  #10  
Old 03-11-2008, 02:53
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default As for Groups...

If you want to group your ActiveSelectionRange it would be like this:
Code:
Set s = ActiveSelectionRange.Group
Best of luck,

-Shelby
Reply With Quote
Reply

Tags
text


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Select All Text On a Layer knowbodynow CorelDRAW/Corel DESIGNER VBA 2 24-05-2007 21:08
Dimension presets affect line endpoint default corel designer whiner Feature requests/wishlist 0 28-06-2006 14:17
Select specified text, change font size? fiddler2b CorelDRAW/Corel DESIGNER VBA 3 23-04-2006 09:11
Select Paragraph Text with more than one color joexx CorelDRAW/Corel DESIGNER VBA 2 06-10-2004 13:20
Select All ddonnahoe CorelDRAW/Corel DESIGNER VBA 4 10-02-2004 10:14


All times are GMT -5. The time now is 01:50.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com