Solved

Adobe reader can't open pdf file from shellexecute

Posted on 2007-11-29
6
2,871 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

821 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