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.
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