CorelDraw VBA macro error: "Object Required"

CorelDraw VBA macro error: "Object Required"

我正在为 CorelDraw 创建一个宏,它会在按下名为 Generate 的按钮时从给定文件夹导入文件。尝试将文件路径分配给变量时,出现以下错误:

Object Required

这是我的代码:

Private Sub UserForm_Initialize()

    'Design Of Item'

    Me.DesignList.AddItem ("BIFT")
    Me.DesignList.AddItem ("BIFC1")
    Me.DesignList.AddItem ("BIFC2")
    Me.DesignList.AddItem ("BIFI")

    'Type Of Item'

    Me.TypeList.AddItem ("BIF HOODIE")
    Me.TypeList.AddItem ("BIF T-SHIRT")
    Me.TypeList.AddItem ("BIF SWEAT")
    Me.TypeList.AddItem ("BIF TANK")

    'Colours of the items'

    Me.ColourList.AddItem ("Grey")
    Me.ColourList.AddItem ("White")
    Me.ColourList.AddItem ("Black")
    Me.ColourList.AddItem ("Navy")

    Dim Design As String
    Dim Ctype As String
    Dim Colour As String
    Dim ShirtFPath As String

End Sub

Private Sub GenerateBtn_Click()
    Set ShirtFPath = ("C:\Users\Matt\Pictures\Clothing Line\Shirts")
    MsgBox (ShirtFPath)
    Set Design = DesignList.Value
    Set Ctype = TypeList.Value
    Set Colour = ColourList.Value
End Sub

Private Sub SaveBtn_Click()

    Dim fPath As Object
    Dim sr As ShapeRange

    Set fPath = Me.TB.Value
    If fPath Is Nothing Then Exit Sub
End Sub

您仅使用 Set 进行对象分配。对于内部类型(数字、字符串、布尔值),省略单词 Set:

ShirtFPath = "C:\Users\Matt\Pictures\Clothing Line\Shirts"
Design = DesignList.Value
Ctype = TypeList.Value
Colour = ColourList.Value