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?
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

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 = ""
 

Watch MrExcel Video

Forum statistics

Threads
1,122,233
Messages
5,594,963
Members
413,954
Latest member
mrsandy

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