I need to automate some process. I wrote some code to publish cdr files as 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
Marked line makes error: the document cannot be closed from the document event handler . So the question is: how close this document without close whole application?
Create shortcut key for 'Close" and use Sendkeys for it.
Tested on X6.