Fill selected object by file.

Hello all,

I have searched for weeks now and can not figure out this problem.

all I want to do is ues a .Fill file to fill a selected object.  I have used the record macro feature and came up with this code

Sub TemporaryMacro()
    ' Recorded 7/13/2019
    Dim OrigSelection As ShapeRange
    Set OrigSelection = ActiveSelectionRange
    OrigSelection(1).Style.StringAssign "{""fill"":{""type"":""9"",""primaryColor"":""CMYK255,USER,0,0,0,0,100,cccd19cb-4675-4a5e-8bda-d0bbbaab8af0"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000"",""overprint"":""0"",""tilingInterTileOffset"":""0"",""tilingHeight"":""1016000"",""tilingFlagsMirrorVertical"":""0"",""fillName"":""cc613529-4bf9-4200-93f9-14cc2b217794.24.colorbitmap"",""tilingXOffset"":""0"",""tilingFlagsNoSeams"":""0"",""tilingFlagsMirrorHorizontal"":""0"",""tilingWidth"":""1016000"",""tilingFlagsColumnOffset"":""0"",""tilingFlagsScale"":""0"",""tilingFlagsScaleToObject"":""0"",""skew"":""0"",""tilingYOffset"":""0"",""angle"":""0""},""outline"":{""color"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""width"":""1764""},""transparency"":{}}"
    OrigSelection(1).Style.StringAssign "{""fill"":{""type"":""9"",""primaryColor"":""CMYK255,USER,0,0,0,0,100,cccd19cb-4675-4a5e-8bda-d0bbbaab8af0"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000"",""overprint"":""0"",""tilingInterTileOffset"":""0"",""tilingHeight"":""1016000"",""tilingFlagsMirrorVertical"":""0"",""fillName"":""980ea7ed-30d3-4800-97b9-7c561de7db79.23.colorbitmap"",""tilingXOffset"":""0"",""tilingFlagsNoSeams"":""0"",""tilingFlagsMirrorHorizontal"":""0"",""tilingWidth"":""1016000"",""tilingFlagsColumnOffset"":""0"",""tilingFlagsScale"":""0"",""tilingFlagsScaleToObject"":""0"",""skew"":""0"",""tilingYOffset"":""0"",""angle"":""0""},""outline"":{""color"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""width"":""1764""},""transparency"":{}}"
End Sub

The file that I am trying to load is "C:\Users\username\Documents\Corel\Corel Content\Fills\ Starter pack\Bitmap Pattern 021.fill"

It will work fine with the recorded code on one computer but will not run on a different computer, both computers have the same file,

I have tried replacing the "fillName"":""980ea7ed-30d3-4800-97b9-7c561de7db79.23.colorbitmap" section with the file path but this dose not work on either computer.

Anyone have any Idea how to make this work. If it makes a difference I can move all 300 colors to a shared network drive so all the computer are reading from the same file. not there own user name folder.

Just to clarify all i want to do is fill the selected object using a .fill file seams like this should be easy but I give up.

Thank you in advance for any help.

Parents
No Data
Reply
  • I don't know how to use a .fill file through the API. I do know how to apply a bitmap pattern fill by specifying a bitmap to use.

    This code will apply a bitmap pattern fill to a single selected object, based on the file "test_tile.png" specified in the code.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    Sub test_bitmap_pattern_fill()
    Dim sr As ShapeRange
    Dim s As Shape
    Dim pfThis As PatternFill
    Const dblTileWidth As Double = 1
    Const dblTileHeight As Double = 1
       
        If Not ActiveDocument Is Nothing Then
            Set sr = ActiveSelectionRange
            If sr.Count = 1 Then
                Set s = sr(1)
                If s.CanHaveFill Then
                    Set pfThis = s.Fill.ApplyPatternFill(cdrBitmapPattern, "D:\test_tile.png")
                    pfThis.TileHeight = dblTileWidth
                    pfThis.TileWidth = dblTileHeight
                End If
            Else
                MsgBox "Selection must be a single shape."
            End If
        Else
            MsgBox "No document is active."
        End If
    End Sub
    

    The tile width and height are set by constants in the macro; adjust as suits your need.

    There are other properties that could be set for the fill, e.g., offset, skew, rotation, and whether the fill transforms with the shape.

    Here's the file I used for the bitmap. I'm sharing it on Google Drive because the forum software won't allow upload of a file that large. The .fill file is a ZIP file, and that's where I got the bitmap:

    test_tile.png

    .

Children