请教这个怎么用

使用问题 · 70 次浏览
1507572666 创建于 2026-06-28 11:29

大佬   有没有现成的功能让试用下


回复内容
Mrshuang 2026-06-29 08:31
#1

 

Dim app, doc, lyr, line

On Error Resume Next

Set app = GetObject(, "CorelDRAW.Application")

If Err.Number <> 0 Then
    Err.Clear
    Set app = CreateObject("CorelDRAW.Application")
End If

If Err.Number <> 0 Then
    MsgBox "无法启动或连接 CorelDRAW,请确认 CorelDRAW 已正确安装,并且支持 COM/VBA 自动化。"
    WScript.Quit
End If

On Error GoTo 0

app.Visible = True

If app.Documents.Count = 0 Then
    Set doc = app.CreateDocument
Else
    Set doc = app.ActiveDocument
End If

Set lyr = doc.ActiveLayer

' 使用英寸单位,避免 CorelDRAW 常量识别问题
' 4.5cm = 4.5 / 2.54 inch
doc.Unit = 1

Set line = lyr.CreateLineSegment(2, 2, 2, 2 + 4.5 / 2.54)

line.Outline.Width = 0.01

回复主贴