I am wanting to programmatically perform a powerclip, where an image is inserted into a shape, or rather, the shape is used to powerclip the image.
I have created a circle, and imported a picture.
The object model diagram shows this:
and the PowerClip does have an ExtractShapes method, but nothing I find goes "the other way"..
Dim ellipse1 As ShapeDim picture As Shape ' picture is the jpg image' create a circle shapeSet ellipse1 = ActiveLayer.CreateEllipse(20, 30, 25, 35)' import an image, to be clipped into the circleActiveLayer.Import "C:\temp\PIC1.jpg"Set picture = ActiveLayer.Shapes("PIC1.jpg")' how to "PowerClip Inside" this picture into the ellipse1?
Thanks in advance
Keith,
You just need to use the AddToPowerClip. Like this.
Sub TestingAddToPowerClip() Dim ellipse1 As Shape Dim picture As Shape ' picture is the jpg image ' create a circle shape Set ellipse1 = ActiveLayer.CreateEllipse(20, 30, 25, 35) ' import an image, to be clipped into the circle ActiveLayer.Import "C:\temp\PIC1.jpg" Set picture = ActiveLayer.Shapes("PIC1.jpg") 'Adds image to Ellipse picture.AddToPowerClip ellipse1 End Sub
Happy coding,
-Shelby
Hi Shelby,
Thanks for the reply.
On the line "picture.AddToPowerClip (ellipse1)"
I get this exception:
And this is CorelDraw 2018.
the method does show in the list of methods for 'picture', furthermore, the argument list for AddToPowerClip also shows as:
Have any ideas why I get an exception?
Take out the parentheses
Gak... kicking self...
So what good are the parens?
Also, is there any kind of documentation on the various methods?
Thanks for assistance!!
The parentheses are used when you are returning something. like on your line that you are assigning the Pic1.jpg to a shape.
Set picture = ActiveLayer.Shapes("PIC1.jpg")
You can find the API documention here for 2018:
API Documentation - Developer Area - CorelDRAW CommunityI find it very difficult to search but clicking around works. If you want a userful search, I would download the old CorelDRAW VBA Help file. It is older, so it doesn't have everything, but so much easier to search.
You can download the old help file here:
CorelDRAW VBA Help File