Solved

Adobe reader can't open pdf file from shellexecute

Posted on 2007-11-29
6
2,884 Views
Last Modified: 2010-04-21
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

0
Comment
Question by:Link-HRSystems
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 20374436
any code sample would be appreciated

ziolko.
0
 

Author Comment

by:Link-HRSystems
ID: 20374494
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

0
 
LVL 18

Expert Comment

by:Johnjces
ID: 20375450
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Accepted Solution

by:
ziolko earned 125 total points
ID: 20380395
first of check if ShellFindExecutable() returns correct path
then try this:
ShellExecute(hInstance, 'open', PChar(sExecutable), pChar(filename), nil,  SW_SHOW);
or
ShellExecute(hInstance, 'open', nil, pChar(filename), nil,  SW_SHOW);

ziolko.
0
 

Author Comment

by:Link-HRSystems
ID: 20380951
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
0
 

Author Closing Comment

by:Link-HRSystems
ID: 31411686
This did answer my question wasn't my full issue, my mistake I will post another question.

Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question