ACC2000 - API ShellExecute Wait until File loads

T

Tony_VBACoder

I am trying to use various API calls to launch a PDF file in Acrobat, and
wait until the file has fully loaded before continuing on in my code, so that
I can grab the Window Handle ID of the newly opened PDF window.

I am trying to attach this code to a button's click event that will do the
following:

#1 Call the API ShellExcute to load a PDF document:
Public Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long

#2 - Wait until the file has had a chance to fully load before continuing
onto the next step

#3 - Grab the FileHandle to the window where this PDF opened.

Does anyone has any sample VBA code that would accomplish this?
 
T

Tony_VBACoder

Alex, thanks for this link, however, this does not work for my situation.

This code sample waits until the application, not the specific file, exits
before it continues with the next line of code. I need an API call to wait
until my file finishes loading within the application, before my next line of
code executes. For instance, this code works great if I wanted to run
Calculator ("C:\WINDOWS\system32\calc.exe") and when I quit Calculator, the
next line of code executes. However, I need it to wait until my PDF file
finishes loading ("C:\Temp\MyPDF.PDF") within Acrobat. If I try and pass the
path to my PDF document, I get the error message "Invalid procedure call or
argument" when I try the code listed in the link you sent me.

Thanks.
 
A

Alex Dybenko

Hi,
hmm, then I think you can only try to catch this event in Acrobat. Try to
look at it object model, then you can start Acrobat via CreateObject() and
open document there
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top