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 09-05-2007, 13:51
Manuel
Guest
 
Posts: n/a
Default Use shapes in a range

I Draw a comic strip and I always scan my drawings and work with them in Corel by placing them in four frames and adding text, so I wrote a little macro that reduces the selected scans and places them inside the frames.

This is the code:

Code:
Sub PlaceInFrames()
    
    Dim sr As ShapeRange
    Dim s1 As Shape, s2 As Shape, s3 As Shape, s4 As Shape
        
    Set sr = ActiveSelectionRange
    
    sr.Stretch 0.598
        
    Set s1 = ActivePage.Shapes("Rectangle1")
    Set s2 = ActivePage.Shapes("Rectangle2")
    Set s3 = ActivePage.Shapes("Rectangle3")
    Set s4 = ActivePage.Shapes("Rectangle4")
       
    sr(1).AlignToShape cdrAlignBottom + cdrAlignHCenter, s1
    sr(1).AddToPowerClip s1
    sr(2).AlignToShape cdrAlignBottom + cdrAlignHCenter, s2
    sr(2).AddToPowerClip s2
    sr(3).AlignToShape cdrAlignBottom + cdrAlignHCenter, s3
    sr(3).AddToPowerClip s3
    sr(4).AlignToShape cdrAlignBottom + cdrAlignHCenter, s4
    sr(4).AddToPowerClip s4
    
        
End Sub
This code didn't work, I had to define four additional shape variables from each one of the selected range and then work with them.

This is the code that works:

Code:
Sub PlaceInFrames()
    
    Dim sr As ShapeRange
    Dim s1 As Shape, s2 As Shape, s3 As Shape, s4 As Shape
    Dim sr1 As Shape, sr2 As Shape, sr3 As Shape, sr4 As Shape
    
    Set sr = ActiveSelectionRange
    
    sr.Stretch 0.598
        
    Set sr1 = ActiveSelectionRange(1)
    Set sr2 = ActiveSelectionRange(2)
    Set sr3 = ActiveSelectionRange(3)
    Set sr4 = ActiveSelectionRange(4)
    Set sr = Nothing
    Set s1 = ActivePage.Shapes("Rectangle1")
    Set s2 = ActivePage.Shapes("Rectangle2")
    Set s3 = ActivePage.Shapes("Rectangle3")
    Set s4 = ActivePage.Shapes("Rectangle4")
       
    sr1.AlignToShape cdrAlignBottom + cdrAlignHCenter, s1
    sr1.AddToPowerClip s1
    sr2.AlignToShape cdrAlignBottom + cdrAlignHCenter, s2
    sr2.AddToPowerClip s2
    sr3.AlignToShape cdrAlignBottom + cdrAlignHCenter, s3
    sr3.AddToPowerClip s3
    sr4.AlignToShape cdrAlignBottom + cdrAlignHCenter, s4
    sr4.AddToPowerClip s4
    
End Sub
Why didn't it work the first time when I tried to use the four items in the ShapeRange? Remember I'm totally new to VBA or any form of programming.

Thanks
Reply With Quote
  #2  
Old 09-05-2007, 13:55
Manuel
Guest
 
Posts: n/a
Default

I forgot to explain this: The "activeselectionrange" that I use for my variable "sr" is the four scans that I import in my document and then select them all at the same time.
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
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 15:14
CorelDRAW X3 VBA Code - Shape & Color LIster JudyHNM Code Critique 2 05-04-2007 14:02
Deleting Shapes on the Guides Layer Rick Randall CorelDRAW/Corel DESIGNER VBA 2 28-09-2004 11:07
Transfer shapes from Draw to Paint; Using CorelScript in VB6 DWGraphics Corel Photo-Paint VBA 1 18-08-2004 20:49
Generic code to process all shapes in a document glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 03:13


All times are GMT -5. The time now is 12:40.


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