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 10-02-2010, 23:19
misteralien
Guest
 
Posts: n/a
Default get selection text help

can someone help me with this? i want the macro to get the text at the selected shape. this is obviously not working. thanks.

Sub getselectiontext()
ActiveDocument.Pages(pagenum).ActiveLayer.Activate
ActivePage.SelectShapesAtPoint(2.3, 9.88, True).CreateSelection
Set shRange = ActiveSelectionRange
MsgBox shRange.Shapes.Count

For Each stext In shRange.FindShapes(Type:=cdrTextShape)
Set tr = stext.Text.Story.Duplicate
MsgBox tr

Next stext


' If s.Type = cdrTextShape Then s.Text.Story = "New Text": Stop

End Sub
Reply With Quote
  #2  
Old 11-02-2010, 07:41
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
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 GetText

Give this a try:
Code:
Sub getselectiontext()
    Dim tr As New ShapeRange, sText As Shape, sel As Shape
    
    ActiveDocument.ShapeEnumDirection = cdrShapeEnumBottomFirst
    Set sel = ActivePage.SelectShapesAtPoint(2.3, 9.88, True)
    
    For Each sText In sel.Shapes.FindShapes(Type:=cdrTextShape)
        tr.Add sText.Duplicate
    Next sText
End Sub
Best of luck,
-Shelby
Reply With Quote
  #3  
Old 11-02-2010, 21:42
misteralien
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by shelbym View Post
Give this a try:
Code:
Sub getselectiontext()
    Dim tr As New ShapeRange, sText As Shape, sel As Shape
    
    ActiveDocument.ShapeEnumDirection = cdrShapeEnumBottomFirst
    Set sel = ActivePage.SelectShapesAtPoint(2.3, 9.88, True)
    
    For Each sText In sel.Shapes.FindShapes(Type:=cdrTextShape)
        tr.Add sText.Duplicate
    Next sText
End Sub
Best of luck,
-Shelby
awesome! thanks!!! do you know why the for next loops has to run through 3 times? it's ok if it does. just wondering.
Reply With Quote
  #4  
Old 12-02-2010, 00:51
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,787
Blog Entries: 11
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 Loop

Because it is finding each text object then duplicating them. You could do it like this and avoid the loop altogether.
Code:
Sub getselectiontext()
    Dim tr As New ShapeRange, sText As Shape, sel As Shape
    
    ActiveDocument.ShapeEnumDirection = cdrShapeEnumBottomFirst
    Set sel = ActivePage.SelectShapesAtPoint(2.3, 9.88, True)
    
    sel.Shapes.FindShapes(Type:=cdrTextShape).Duplicate
End Sub
Best of luck,

-Shelby
Reply With Quote
  #5  
Old 15-02-2010, 00:02
misteralien
Guest
 
Posts: n/a
Default thanks

Shelby,
Thanks again! =D
Reply With Quote
Reply


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
get selection text help misteralien General 0 10-02-2010 23:17
Bug with existing selection m31uk3 Code Critique 1 02-01-2008 18:18
Text selection and sizing ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 17-05-2005 13:19
Text selection problem ken_ac CorelDRAW/Corel DESIGNER VBA 2 10-02-2004 20:24
Selection of Text off-page D_Green CorelDRAW/Corel DESIGNER VBA 2 04-10-2003 16:34


All times are GMT -5. The time now is 17:34.


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