Sub VectorPattern_random1() Applying, but something like this, please please someone edit this



Sub VectorPattern_random1()
Dim OrigSelection As ShapeRange
Dim s As shape
Dim patternFolder As String
Dim patternFiles As Collection
Dim file As String
Dim randomPatternFile As String
Dim fileIndex As Integer

On Error Resume Next ' Resume execution on error

' Define the path to the CorelDRAW default pattern folder
patternFolder = "C:\Users\admin\Documents\Corel\Corel Content\Fills\Vector\"

' Initialize the collection to hold the pattern file names
Set patternFiles = New Collection

' Get the list of .FILL files in the folder
file = Dir(patternFolder & "*.fill")
Do While file <> ""
patternFiles.Add patternFolder & file
file = Dir
Loop

' Check if any pattern files were found
If patternFiles.count = 0 Then
MsgBox "No pattern files found in the specified folder: " & patternFolder, vbExclamation, "Error"
Exit Sub
End If

' Get the selected shapes
Set OrigSelection = ActiveSelectionRange

' Loop through each shape in the selection
For Each s In OrigSelection
' Select a random pattern file from the collection
Randomize ' Initialize random number generator
fileIndex = Int((patternFiles.count) * Rnd + 1)
randomPatternFile = patternFiles(fileIndex)


' Apply the vector pattern fill
Dim frontColor As New Color
Dim endColor As New Color

' Set default colors (you may adjust these as needed)
frontColor.CMYKAssign 0, 0, 0, 0 ' Example front color (black)
endColor.CMYKAssign 0, 0, 0, 0 ' Example end color (black)

' Construct the style string for the pattern fill
Dim patternStyle As String
patternStyle = "{""fill"":{""angle"":""0"",""anisotropic"":""1"",""fillName"":""" & randomPatternFile & """,""fountainType"":""4"",""intermediateColors"":[],""mergeMode"":""0"",""mode"":""0"",""numSteps"":""0"",""overprint"":""0"",""primaryAlpha"":""255"",""primaryColor"":""CMYK,USER,25,9,3,22,100,00000000-0000-0000-0000-000000000000"",""rateAcceleration"":""0"",""rateMethod"":""0"",""rateValue"":""50"",""screenSpec"":""0,0,45000000,60,0"",""secondaryAlpha"":""255"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000"",""skew"":""-90"",""spreadMethod"":""0"",""tilingFlagsColumnOffset"":""0"",""tilingFlagsMirrorHorizontal"":""0"",""tilingFlagsMirrorVertical"":""0"",""tilingFlagsNoSeams"":""0"",""tilingFlagsScale"":""0"",""tilingFlagsScaleToObject" & _
""":""0"",""tilingHeight"":""0"",""tilingInterTileOffset"":""0"",""tilingWidth"":""0"",""tilingXOffset"":""0"",""tilingYOffset"":""0"",""type"":""10"",""vectorBoundingBox"":""-63501,381000,444499,-127000"",""vectorOriginalBoundingBox"":""-63501,381000,444499,-127000"",""xCenterOffset"":""0"",""xScale"":""1"",""yCenterOffset"":""0"",""yScale"":""1""},""outline"":{""color"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""overprint"":""0"",""width"":""0""},""transparency"":{""fill"":{""fillName"":null,""overprint"":""0"",""type"":""0""},""uniformTransparency"":""0.309999999999999997779553950749686919152736663818359375""}}"

' Apply the pattern fill using the constructed style string
s.Style.StringAssign patternStyle
Next s

End Sub