I'm trying to create a macro to apply my custom bitmap pattern fill.I found this https://community.coreldraw.com/sdk/api/draw/18/m/fill.applypatternfill but when I use the example macro and change the path to my custom .fill file, I get an error that it failed to load.
Sub Test() Dim s As Shape Set s = ActiveLayer.CreateRectangle(0, 0, 5, 5) s.Fill.ApplyPatternFill cdrBitmapPattern, "C:\Users\jchestnut\Documents\Corel\Corel Content\Fills\CoolerWrap Wood 1.fill" End Sub
Try to use following code
Sub Test() Dim s As Shape Set s = ActiveLayer.CreateRectangle(0, 0, 5, 5)ActiveSelection.Fill.ApplyFountainFill s.Style.Fill.LoadFill ("c:\Gold Leaf.fill") 'path to your file *.fillEnd Sub
Edit: your code is working with bitmap fills
That worked! But how do I get it to apply the fill to my active selection? I already have blank rectangles created and want to apply the fill to those.
I got it. Thanks Mek!
Dim s As Shape Dim sr As ShapeRange Set sr = ActiveSelectionRange For Each s In sr.Shapes s.Fill.ApplyFountainFill s.Style.Fill.LoadFill ("C:\Users\jchestnut\Documents\Corel\Corel Content\Fills\CoolerWrap Wood 1.fill") Next s
One more question. Let's say I adjusted the pattern scale to be larger. How would I copy that new scale to the other shapes with VBA? I can do it manually with the attributes eyedropper tool.