Consulting

Results 1 to 5 of 5

Thread: My macro stops half way through because of a dialog box

  1. #1

    My macro stops half way through because of a dialog box

    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:

    [VBA]
    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.
    [/VBA]

    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.

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    Take a look at this article. 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.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


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

    [VBA]
    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
    [/VBA]

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

  4. #4
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    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.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •