PDF problems - getting error message if a PDF is already open

Hi,

We look at PDF files through Progress using the code below and it has been acceptable for a while.

However when a PDF is already being looked at, chosen from a directory, not through Progress, and the code is run (through a program) then the following message is shown and the required PDF is not displayed.

ADOBE READER ERROR
There was an error opening this document. This file cannot be found.

The Hinstance displays 42 in both scenarios.

Any thoughts as this is starting to cause problems with one user who wants lots of .PDFs to be displayed.


Mike


PROCEDURE ShellExecuteA EXTERNAL "shell32":
DEFINE INPUT PARAMETER HWND AS LONG.
DEFINE INPUT PARAMETER lpOperation AS CHAR.
DEFINE INPUT PARAMETER lpFile AS CHAR.
DEFINE INPUT PARAMETER lpParameters AS CHAR.
DEFINE INPUT PARAMETER lpDirectory AS CHAR.
DEFINE INPUT PARAMETER nShowCmd AS LONG.
DEFINE RETURN PARAMETER hInstance AS LONG.
END PROCEDURE.

def var newfilename as char format "x(30)" no-undo.
assign newfilename = "print\25444680.pdf".
Def var OK as logical NO-UNDO.
def var Filename as char NO-UNDO.
def var hInstance as INT no-undo.



FILE-INFO:File-NAME = ".". /* Current directory */

run ShellExecuteA
(0,
"open",
"AcroRd32.exe",
newfileName,
FILE-INFO:FULL-PATHNAME,
/* starting directory */
1,
output hInstance).

message "have hInstance " hInstance skip
view-as alert-box.
 
Hi Thanks for your reply, but not quite the problem I am having

It is when the user opens up PDF files from different sources - the internet, or a different application and leaves them open that the problem occurs. We don't know what the name of the PDF file is so can't check it via the solution that has been offered.
So what I am asking is there a different way to open PDF files from within a Progress application that does not cause problems, or a way to check the users task list to see if there is a PDF file already open.

Mike

PS nearly forgot again
Windows vista
Progress Version 9.1e
 

Osborne

Active Member
Ah, I see. Adjusting the run ShellExcuteA code a little does not seem to give the error if already open on Windows 7 and 9.1E:

Code:
RUN ShellExecuteA (0,
                   "open",
                   "AcroRd32.exe",
                   newfilename,
                   "",
                   0,
                   OUTPUT hInstance).

However, this only seems to work if the document is open in Acrobat Reader but if open in another application you still get the error.

There is OS-COMMAND but again not perfect:

Code:
ASSIGN FILE-INFO:FILE-NAME = newfilename
       newfilename = FILE-INFO:FULL-PATHNAME.
OS-COMMAND NO-WAIT START "AcroRd32.exe" VALUE('"' + newfilename + '"'). /* Okay if Acrobat Reader has the document open otherwise error. */

OS-COMMAND NO-WAIT VALUE('"' + newfilename + '"'). /* No error but no indication the document is already open. */
 
Top