Solved

Adobe reader can't open pdf file from shellexecute

Posted on 2007-11-29
6
2,861 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now