Hi
Im trying to loop through a series of files exporting them as pdf's and png's. Had a look at wOxxOm's macro which would seem to do exactly what Im after but on Draw 7 it crashes the application - I think this is related to the files not being fully saved before the next is opened.
I couldn't debug the issue so wrote a loop that takes the file names from Excel and encountered the same problem, pausing the macro between loops seems to allow it to work and wonder if someone might help me to get the loops to wait for the last loop to finish before starting the next.
Below is the main code from wOxxOm's macro which I would prefer to get working and beneath that my hash.
Thanks
nic
Code:
Sub psdExport()
Dim file$, expflt As ExportFilter, doc As Document, errs$, report$
Static folder$: If folder = "" Then folder = "H:\test 1"
folder = Application.CorelScriptTools.GetFolder(folder, "Initial folder: " + folder, AppWindow.Handle)
If folder = "" Then Exit Sub
If right(folder, 1) <> "\" Then folder = folder + "\"
On Error GoTo ErrHandler
Application.PanoseMatching = cdrPanosePrompt ' may change to cdrPanoseTemporary
file = Dir(folder + "*.cdr")
Do While file <> ""
Set doc = Application.OpenDocument(folder + file)
If Not doc Is Nothing Then
... do something
NextFile:
file = Dir
Loop
MsgBox report + vbNewLine + "--------------" + vbNewLine + errs, , _
"Processed folder: " + folder
Exit Sub
ErrHandler:
errs = errs + "Error on " + file + ": " + ERR.Description + vbNewLine
ERR.Clear
Resume NextFile
End Sub
Code:
sub excelloop
Dim n As Long
Dim crlfile As String
Dim fullpath As String
Set xl = GetObject(, "Excel.Application")
For n = 1 To 5
crlfile = xl.cells(n, 1).Value
fullpath = "d:\Users\Nic\Desktop\drawfiles\" & crlfile & ".cdr"
Application.OpenDocument (fullpath)
...do something
ActiveDocument.PublishToPDF "d:\Users\user\Desktop\pdfs\" & crlfile & ".pdf"
next n
end sub