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 13-10-2004, 11:52
dan
Guest
 
Posts: n/a
Default Simple Loop?

Hi there,

I'm trying to create a loop (in Coreldraw 11) that does the following to a selected set of curves:

1. checks to see if the curve is open or not, then
2. closes an open curve with a straight line segment, then
2. obtains the RGB color of the outline, then
3. applies this RGB color to a uniform fill

Unfortunately, I'm not that experienced programming in VB and am not at all familiar with the object model in Coreldraw.

Could anyone find it in there heart to post what i believe should be a relatively simple bit of code that i can use and learn from?

Thanks,
Dan
Reply With Quote
  #2  
Old 13-10-2004, 12:13
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default Re: Simple Loop?

Dan,

Here is the code for you:

Code:
Sub ApplyOutlineToFill()
    Dim s As Shape
    Dim clr As New Color
    
    ActiveDocument.BeginCommandGroup "Apply Outline To Fill"
    ' Go through all selected objects
    For Each s In ActiveSelection.Shapes
        ' If it is a curve and it is open, close it
        If s.Type = cdrCurveShape Then
            If Not s.Curve.Closed Then s.Curve.Closed = True
        End If
        
        If s.Type <> cdrGroupShape Then
            ' See if the object has an outline
            If s.Outline.Type = cdrOutline Then
                ' Get the outline color
                clr.CopyAssign s.Outline.Color
                ' Convert it to RGB
                clr.ConvertToRGB
                ' Apply to the fill
                s.Fill.ApplyUniformFill clr
            End If
        End If
    Next s
    ActiveDocument.EndCommandGroup
End Sub
If you have any questions about it, please let me know.
Reply With Quote
  #3  
Old 13-10-2004, 13:10
dan
Guest
 
Posts: n/a
Default

Alex,

This code worked like a charm... first shot. Thanks so much!! My "workaround" to accomplish this same thing was so cumbersome that it's too embarrasing to even share it with you.

Now all i have to do is go buy a book and learn to do simple things like your code did for me. I might get so much more accomplished in a day that i can start leaving work early to play golf .

Dan
Reply With Quote
  #4  
Old 13-10-2004, 14:31
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Be sure to start with CorelDRAW programming guide which is included in your CorelDRAW installation (as a PDF file). Look for dvba_pg.pdf (yes, I know, the name is weird, but the content is a treasure though)...
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
Simple Bar code generator Webster Code Critique 2 06-09-2010 02:41
Installer for GMS ssb CorelDRAW/Corel DESIGNER VBA 8 15-02-2005 03:22
simple example chinkyk CorelDRAW/Corel DESIGNER VBA 3 19-10-2004 15:50
exporting to jpg ddonnahoe CorelDRAW/Corel DESIGNER VBA 7 26-01-2004 12:53
Condition #1002 -Listman- 0737 (Wierd memory leaks issues) wbochar CorelDRAW/Corel DESIGNER VBA 6 15-05-2003 17:48


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


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