Solved

Adobe Execute Problem

Posted on 2004-10-04
10
392 Views
Last Modified: 2013-12-18
Hi

I need the code which would pick up the correct version of Adobe that the user has installed and then execute accordingly, at present all that i can do is hard code.

Any ideas, the following code is from the button.


@Command( [Execute]; "C:\\Program Files\\Adobe\\Acrobat 5.0
\\Reader\\AcroRd32.exe"; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" )


Thanks
0
Comment
Question by:DavidAbbott
  • 5
  • 4
10 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12218622
Use this command to find the exe that is assocuiated with recent version of acrobat

@regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command")

This will return the exe file path

~Hemanth
0
 

Author Comment

by:DavidAbbott
ID: 12224641
Thanks for the reply would the code be something like this?

@Command( [Execute]; @regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command")
; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" )
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12226744
yes.. but before that check the registry value is not null !!

eg;
pdfExec := @regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command");
@if( pdfExec = ""; @Prompt([ok];"Error";"No executable found to launch the file !"); @Command( [Execute]; pdfExec ; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" ) )
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 12228546
Not quite.  The registry query will return something like:
"C:\Program Files\Adobe\Acrobat 6.0\Reader" "%1"

So, you need to pull off the first string as the executable name: "C:\Program Files\Adobe\Acrobat 6.0\Reader"
And, you should dorp the quotes: C:\Program Files\Adobe\Acrobat\Reader

What might work better for you is querying HKCR Software\Adobe\Acrobat\Exe
...which is Ibelieve what Adobe recommends!
0
 

Author Comment

by:DavidAbbott
ID: 12246306
Ok, thanks for the help, but am even more confused now
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12250663
why ?

You have to choose appropriate key that is it
0
 

Author Comment

by:DavidAbbott
ID: 12251001
the error message keeps being returned!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12251553
What is the error msg ?
0
 

Author Comment

by:DavidAbbott
ID: 12251580
"No executable found to launch the file !"
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 500 total points
ID: 12252023
Looks like that function can read only name value pair... and cannot read (Default) entries...

Only option left out is win32 API call..

Copy this into a ScripLibrary and use shell to execute your attachment

'OPTIONS SECTION
Option Public
Option Declare
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const ERROR_SUCCESS = 0&


' DECLARATIONS SECTION
Declare Function RegOpenKey Lib "advapi32" Alias "RegOpenKeyA" (Byval hKey As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32" (Byval hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, Byval lpData As String, lpcbData As Long) As Long


Function GetRegistryValue(hkey,SubKey As String,ValueName As String)
      Dim phkResult As Long, lResult As Long
      
      Dim tmppath$,filename$,path$
      Dim buflen As Long
      Dim valuetype As Long
      Dim key$
      
      lResult=RegOpenKey(hKey, SubKey, phkResult)
      If lResult<>ERROR_SUCCESS Then
            Messagebox "Error opening registry..."
            Exit Function
      End If
      tmppath$ = String(256, " ")
      buflen = Len(tmppath$)
      valuetype=1
      lResult = RegQueryValueEx(phkResult, ValueName, 0, valuetype, tmppath$, buflen)
      If lResult<>ERROR_SUCCESS Then
            Messagebox "Error getting value..."
            RegCloseKey phkResult
            Exit Function
      End If
      RegCloseKey phkResult
      GetRegistryValue=Left$(tmppath$, buflen-1)
End Function



USING THIS LIBRARY
=============

Include this into your form or agent..

second, use this to extract key value and execute file
      FilePath = "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf"
      adobePath = GetRegistryValue(HKEY_CLASSES_ROOT, "Software\Adobe\Acrobat\Exe", "")
      If adobePath <> "" Then
            tast% = Shell(adobePath + " " + FilePath )
      End If
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

16 Experts available now in Live!

Get 1:1 Help Now