Link to home
Start Free TrialLog in
Avatar of Link-HRSystems
Link-HRSystems

asked on

Adobe reader can't open pdf file from shellexecute

I use a shellexecute command to open a pdf document from a delphi app. After upgrading Adobe Reader to 8.1.1 it no longer works and I get the error message:

There was an error opening this document. The file cannot be found.

The file can be opened from within Adobe Reader without any problems. It worked fine before 8.1.1.

Andy help would be appreciated. Thanks

Open in new window

Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

any code sample would be appreciated

ziolko.
Avatar of Link-HRSystems
Link-HRSystems

ASKER

Here you go if it helps.

Thanks
filename := ExtractFilePath(Application.ExeName)+ 'Documentation\'+ pdffile;
 
sExecutable := ShellFindExecutable(filename,ExtractFilePath(filename));
 
ShellExecute(hInstance, nil, PChar(sExecutable), pChar(filename), nil,
        SW_SHOW);

Open in new window

Would you please try

if shellexecute(handle, nil, Pchar(filename), nil, nil, SW_SHOW) < 32 then
    ShowMessage('Unable to open file');

As long as the .pdf extension is properly registered, (or any other extension) this should open Adobe and the file so there is no need of specifying the executable.

Therfor filename has to be the complete path filename and .pdf extension.

John
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the replies.

John
I can open the file using just the filename but I need to specify page number as well, that is why I was using Parameters.

Does anyone have the syntax to specify a page number as well?

Thanks
This did answer my question wasn't my full issue, my mistake I will post another question.

Thanks