繁体   English   中英

Coreldraw VBA GlobalMacroStorage:如何在打开后关闭活动文档?

[英]Coreldraw VBA GlobalMacroStorage: How to close active document after open?

我需要自动化一些过程。 我写了一些代码以cdr格式发布cdr文件:

Sub GlobalMacroStorage_DocumentOpen(ByVal doc As Document, ByVal FileName As String)    
Set doc = ActiveDocument
With doc.PDFSettings
...{some code here}
.Linearize = True
.PageRange = "1,2"
.pdfVersion = pdfVersion13
.PublishRange = pdfPageRange
.TrueTypeToType1 = True
.TextAsCurves = True
.OverprintBlackLimit = True
End With

If Len(Dir(doc.FilePath + "\coreltmp", vbDirectory)) = 0 Then
MkDir doc.FilePath + "coreltmp"
End If
name2 = Dir(FileName) + "TEST.pdf"
 strName = doc.FilePath & "coreltmp" & "\" & name2
doc.PublishToPDF strName
ActiveDocument.Close  <<=====ERROR LINE
End Sub

标记线导致错误:无法从文档事件处理程序中关闭文档。 所以问题是:如何在不关闭整个应用程序的情况下关闭此文档?

在您的情况下doc = ActiveDocument 只需简单地使用:

doc.Close

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM