Pause code

L

Legacy 15162

Guest
Would anyone know the command to place a pause in code to let print command complete?

I am using a pdfconverter called pdfmachine. I am looping through a workbook with 93 sheets, each one having to be its own pdf file. to do this is use a command line executable that is available for download at their website. the problem i seem to be encountering is that it is not name my files correctly. If i go through the code sheet by sheet letting the executable have time to complete its conversion i have no problem with the naming being incorrect......If i just let the macro execute it seems like it has too much information being thrown at it too quickly. If i could pause the code to let the executable complete, i think i would be fine.

Code:
Set xlOrigWB = ActiveWorkbook
For i = 1 To xlOrigWB.Worksheets.Count
    Set xlCopyWB = xlOrigWB
    Set xlWS = xlCopyWB.Worksheets(i)
    stWkshtName = xlWS.Name
    If stWkshtName <> "APC" And stWkshtName <> "LA-TX" And stWkshtName <> "Carolinas" And stWkshtName <> "Cen LA" And stWkshtName <> "South LA" And stWkshtName <> "West Laf" And stWkshtName <> "Midland" And stWkshtName <> "Odessa" And stWkshtName <> "N Charlotte" And stWkshtName <> "SW Charlotte" And stWkshtName <> "E Charlotte" And stWkshtName <> "W Charlotte" And stWkshtName <> "C Charlotte" And stWkshtName <> "CONTROL" And stWkshtName <> "Administrative" Then
        xlWS.Copy
'        lngPeriod = Right(xlWS.Cells("C1"), 2)
        Set xlCopyWB = ActiveWorkbook
        NewFileName = "\\test\Poll\StoreUpld\" & stWkshtName & "pnlp" & stPeriod
        xlCopyWB.SaveAs (NewFileName)
        xlCopyWB.Close
        retval = Shell("\\test\poll\StoreUpld\pdfMachineCmdLine.exe " & NewFileName & ".xls " & NewFileName & ".pdf")
        'Do Until retval = ""
        'Loop
        Shell ("del " & NewFileName & ".xls")
    End If
Next i
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try with WAIT

1st example

<font face=Courier New>newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
</FONT>

2nd example

<font face=Courier New><SPAN style="color:#00007F">If</SPAN> Application.Wait(Now + TimeValue("0:00:10")) <SPAN style="color:#00007F">Then</SPAN></FONT>

Ciao
 
Upvote 0
actually, i tried wait, but because the code is coming from excel it is pausing the application before it can complete the command line send.....i am actually going to try the timer function and see how that pans out.....i will post with the code if it suceeds.
 
Upvote 0
i tried completely removing the code and performing the function from access but i still run into the same problem.....what i really need to do is find some code on identifying when i print job completes.....Any ideas?
 
Upvote 0

Forum statistics

Threads
1,220,951
Messages
6,157,030
Members
451,392
Latest member
malcv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top