我需要自动化某个过程。我写了一些代码来将cdr文件发布为PDF:
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
标记的行会出错:无法从文档事件处理程序中关闭文档。所以问题是:如果没有完整的应用程序,这份文件有多接近?
答案 0 :(得分:0)
在您的情况下 doc = ActiveDocument 。 只需使用:
doc.Close