大佬 有没有现成的功能让试用下
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