getting excel to wait

hainejo

Board Regular
Joined
Jun 27, 2002
Messages
57
I have a macro that prints an excel worksheet as a post script file and saves it to a folder on the server. The file is then converted by Acrobat Distiller into a PDF file and saved into another folder. The macro then tells Outlook to create an e-mail and attach the PDF file. The problem is that the macro executes to fast. It looks to attach the PDF file before Distiller can create it. Is there a way to slow the macro down? I have tried the application.wait command but I don't know how to define the amount of time it should wait. Can anyone help me?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
You can use the Dir function in a loop to wait until the file has been created:

Code:
x = Dir("YourNewFile") ' Change name to include Path
If x = "" Then
   Do
      x = Dir()
      DoEvents
   Loop While Dir = ""
End If
 

hainejo

Board Regular
Joined
Jun 27, 2002
Messages
57
I am getting an error on the line
'x = Dir()'
I am getting Invalid procedure call or argument.
 

rikrak

Active Member
Joined
Aug 21, 2002
Messages
255
Hi,

Hope this works:
Do
x = Dir("YourNewFile")
DoEvents
Loop While x = ""
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,545
Messages
5,832,380
Members
430,128
Latest member
ojl987

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
Top