OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 15-09-2014, 02:24
nic nic is offline
Join Date: May 2009
Posts: 90
Default Waiting for Export to finish before continuing

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.


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         

      file = Dir
   MsgBox report + vbNewLine + "--------------" + vbNewLine + errs, , _
      "Processed folder: " + folder
   Exit Sub
   errs = errs + "Error on " + file + ": " + ERR.Description + vbNewLine
   Resume NextFile
End Sub
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

Last edited by nic; 15-09-2014 at 02:28.
Reply With Quote

loop finish, wait

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finish editing power clip contents very slow Kursad General 11 31-01-2008 15:52

All times are GMT -5. The time now is 15:30.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com