PDA

View Full Version : My macro stops half way through because of a dialog box



francozola25
08-27-2008, 12:39 AM
Hi i was wondering could someone help with the following.

My VBA application stops half way through because of an Adobe Dialog Message. I am trying to print off pdfs from a combo box on a VBA drop down userform. It does print off but the macro stop midway.

Is there a way i can use a SendKeys or anything to get around this. I have very little experience of SendKeys but have heard a lot of people do not like using them. I have tried everything else and my application is hanging in the balance because of this.

Please see code:


Call ShellExecute(0, vbNullString, strURL, vbNullString, vbNullString, 0) 'Change 0 to vbNormalFocus to view.
SendKeys "{ENTER}"
PrintURL = ShellExecute(0, "print", strURL, vbNullString, vbNullString, vbHide) 'Change 0 to vbNormalFocus to view.


What it is doing is opening the strURL and printing it off without displaying to the user. It stops half way through that is why i have placed the SendKey here but it still doesn't work. I have also tried a wait command.

CreganTur
08-27-2008, 05:35 AM
Take a look at this article (http://vbaexpress.com/forum/showthread.php?t=16364). It talks about using a freeware program called Click Yes- you can use it to click dialog prompts from external programs. It might be able to help you out.

francozola25
08-27-2008, 07:18 AM
I tried that Cregan but it looks like the button i have is OK. It doesn't seem to work. It is an annoying popup message Acrobat Reader. "This file may contain newer information than this viewer................"

I just have to click OK and it opens the file and prints.

I have also tried the following but i can't get rid of something so small.


Application.ScreenUpdating = False
ReturnValue = Shell("C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", 1)
Call ShellExecute(0, "open", strURL, vbNullString, vbNullString, 0) 'Change 0 to vbNormalFocus to view.
AppActivate (ReturnValue)
Application.Wait (Now + TimeValue("0:00:03"))
SendKeys "{ENTER}", True


It is driving me absolutely nuts!!!!!!!

CreganTur
08-27-2008, 07:44 AM
Have you tried updating Acrobat?

If that doesn't get rid of the message, then click Help -> Detect and Repair; something may be wrong with your reader.

francozola25
08-27-2008, 08:10 AM
Yeah but when i update to Adobe Reader 7.0, it does not function correctly, it displays the pdf file being opened and printed and does not close the file when finished. I cannot seem to get around this unless i install Acrobat Standard 7.0

I don't want to have to do this with all my users and the cost of licenses will not be worth it for just having a document printed off.