473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Invoking a PDF

Hello ... my Dad is dabbling in VB & has a question about invoking a PDF (to
display a help file or manual). Myself, I don't know VB - but I *do* know
how to post to a NG <g>. If anyone has a solution, I would pass it on with
appreciation. Thanks! - Tim

=====================================

I'd like to include in a Visual Basic (VB6) program a command that would
bring up the User's Manual. I'm pretty much settled on the idea that the
manual should be an Acrobat .pdf file (as being the most common
denominator).

It's easy enough to have a statement like:

Shell ("... (tree path) ... Acrord32.exe FileName.pdf,
vbMaximizedFocus)

which works fine on my machine, where I know what the pathname is, but the
problem is, based on a review of our two computers and another, that the
user's machine might have any of a half-dozen versions of acrobat's
PDFreader. So how to find the path and name?

It occurs to me that Windows has some way of solving this. Click on any
..pdf file and Windows opens it with whatever Acrobat reader it chooses (not
neccessarily the latest version on the computer). How does Windows locate a
reader? Is there a simple way I can have my program find it? Or better
still, get it found by some Windows default?
Sep 21 '07 #1
2 4357

"Randy Birch" <rg************@mvps.orgwrote in message
news:01**********************@news.astraweb.com...
Note though that ShellExecute performs the action specified based on the
file association of PDF. If a user or another application has modified
PDF
from opening with Adobe Acrobat, your dad's users won't or may not get the
result he expects.

You can use the FindExecutable API to determine what file is currently
associated with PDF files. Acrobat reader's exe is named either acroread
or
acrord32 depending on the version; the full version of acrobat uses a
different file (acrobat.exe?). To use FindExecutable you point the API at
a
file of interest (e.g. the PDF file or any dummy (empty) file that has a
PDF
extension that you create), and the call returns the executable used to
open
that file based on the registry settings of the user.

By using FindExecutable he can therefore determine/ensure the exe file
name
matches an application appropriate for his PDF help file (by testing the
return value with Instr()), then - his choice - either use exe returned
from
the call to open the PDF file directly (the full path and filename is
returned), or proceed to call Shell Execute knowing that will open the
file
as expected.

A FindExecutable demo can be seen here
(http://vbnet.mvps.org/code/system/findexecutable.htm) and a complete
example of what Shell Execute can do can be seen at
http://vbnet.mvps.org/code/shell/shellexecute.htm

Thanks for the additional info, I have passed it along.

But ... curiously, ShellExecute didn't work for him as expected:
>I never solved the error to the effect that no application was found to
associate with .pdf extention -- which is coo-coo, since clicking on any
.pdf file in Windows Explorer does open it via Acrobat Reader, and I did
find an association via RegEdit.
If invoking a PDF by doubleclicking on it works (opens it in Acrobat
Reader), why would ShellExecute behave any differently?
Sep 23 '07 #2
As mentioned, shellexecute honours the associated file setting in the
registry. As long as the registry entries for pdf and acrobat file are
proper, and the parameters used in making the shellexecute call are valid,
there is no reason why shellexecute would fail that I know of.
--
Randy Birch
MS MVP, Visual Basic
http://vbnet.mvps.org/

Please respond to the newsgroups so all can benefit.
"Tim Reed" <da**************@comcast.netwrote in message
news:a-******************************@comcast.com...

"Randy Birch" <rg************@mvps.orgwrote in message
news:01**********************@news.astraweb.com...
Note though that ShellExecute performs the action specified based on the
file association of PDF. If a user or another application has modified
PDF
from opening with Adobe Acrobat, your dad's users won't or may not get the
result he expects.

You can use the FindExecutable API to determine what file is currently
associated with PDF files. Acrobat reader's exe is named either acroread
or
acrord32 depending on the version; the full version of acrobat uses a
different file (acrobat.exe?). To use FindExecutable you point the API at
a
file of interest (e.g. the PDF file or any dummy (empty) file that has a
PDF
extension that you create), and the call returns the executable used to
open
that file based on the registry settings of the user.

By using FindExecutable he can therefore determine/ensure the exe file
name
matches an application appropriate for his PDF help file (by testing the
return value with Instr()), then - his choice - either use exe returned
from
the call to open the PDF file directly (the full path and filename is
returned), or proceed to call Shell Execute knowing that will open the
file
as expected.

A FindExecutable demo can be seen here
(http://vbnet.mvps.org/code/system/findexecutable.htm) and a complete
example of what Shell Execute can do can be seen at
http://vbnet.mvps.org/code/shell/shellexecute.htm

Thanks for the additional info, I have passed it along.

But ... curiously, ShellExecute didn't work for him as expected:
>I never solved the error to the effect that no application was found to
associate with .pdf extention -- which is coo-coo, since clicking on any
.pdf file in Windows Explorer does open it via Acrobat Reader, and I did
find an association via RegEdit.
If invoking a PDF by doubleclicking on it works (opens it in Acrobat
Reader), why would ShellExecute behave any differently?
Sep 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Prasad | last post by:
We are invoking a SQL DTS component (lets call it Comp1) built by us in another component (Comp2).Comp1 was built by creating the DTS package using the SQL DTS wizard and then saving it as a VB...
6
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
4
by: Joanna Carter \(TeamB\) | last post by:
I am trying to invoke an event using reflection. ////////////////////// public class Test { public event EventHandler NameChanged; public void CallEvent() {
25
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid,...
2
by: shanmani | last post by:
Hi, I am developing a .NET application which will invoke the methods from different COM / .NET DLLs. While invoking methods from .NET DLLs, I am encountering the following error. I have also...
0
by: Haxan | last post by:
Hi, I have an unmanaged application that converts a function pointer to a delegate and then pass this as a parameter(delegate) to a managed function which then invokes it. Currently Im able to...
0
by: balaji krishna | last post by:
Hi, I need to handle the return set from COBOL stored procedure from my invoking Java program. I do not know, how many rows the stored proc SQL fetches.I have declared the cursor in that proc, but i...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
1
by: imranisb | last post by:
Hi, I apologies if this type of question was posted before. I am invoking internet explorer and open the HTTPS website from my c# application like this: System.Diagnostics.Process proc =...
6
by: John O'Flaherty | last post by:
Hello. I have an ms acess database that I use to track my mp3 files. I have included code that lets me select and play files by invoking an mp3 player (Winamp). This is done by using visual basic...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.