UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Retrieving A Value From The Registry, Any Version    
 
   
Marto
post Feb 27 2018, 03:57 AM
Post#1



Posts: 396
Joined: 13-January 03
From: Dublin, Ireland


Hi

I have been trying to get the default location of AcroRd32.exe on various users PC's. I am trying to do this thru the registry as below

Dim ReadValue as string

ReadValue = Registry.GetValue("HKEY_CLASSES_ROOT\Software\Adobe\Acrobat\Exe", "Data", Nothing)

But i keep getting the error "Object Required". I have never worked with the registry so any help would be appreciated.

TIA
Martin

--------------------
There is nothing in the world that some man cannot make a little worse and sell a little cheaper, and he who considers price only is that man's lawful prey.
Go to the top of the page
 
HairyBob
post Feb 27 2018, 05:44 AM
Post#2



Posts: 987
Joined: 26-March 08
From: London, UK


Hi Martin,

Here's something I've had for a while which may help (see attached) - You'll need to change the values passed to gQueryValue() as required.

HTH...

Hairy.
Attached File(s)
Attached File  ReadModifyRegistry.zip ( 47.55K )Number of downloads: 9
 
Go to the top of the page
 
DanielPineault
post Feb 27 2018, 06:43 AM
Post#3


UtterAccess VIP
Posts: 5,951
Joined: 30-June 11



Try:

CODE
CreateObject("WScript.Shell").RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe\")


See: http://www.devhut.net/2012/07/10/VBA-deter...en-application/







I'm curious as to why you actually need to know this since it isn't required to open a PDF?

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
Marto
post Mar 1 2018, 08:20 AM
Post#4



Posts: 396
Joined: 13-January 03
From: Dublin, Ireland


Thank you both for your reply

Daniel,
I am using it to locate the exe so that i can use as per the following

strAdobeLocation = CreateObject("WScript.Shell").RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe\")
Shell strAdobeLocation & " /n /t """ & strDocAndFilePath & """"

The switches are for print and close i have used "Application.FollowHyperlink (strDocAndFilePath)" but it leaves the app open.

Thanks
Martin

--------------------
There is nothing in the world that some man cannot make a little worse and sell a little cheaper, and he who considers price only is that man's lawful prey.
Go to the top of the page
 
DanielPineault
post Mar 1 2018, 08:35 AM
Post#5


UtterAccess VIP
Posts: 5,951
Joined: 30-June 11



Ok, I get it.

I use the following (taken from http://www.devhut.net/2010/06/12/ms-access-VBA-open-a-file/) to open and/or print files
CODE
'Source: [URL="http://www.pacificdb.com.au/MVP/Code/ExeFile.htm"]http://www.pacificdb.com.au/MVP/Code/ExeFile.htm[/URL]
Public Const SW_HIDE = 0
Public Const SW_MINIMIZE = 6
Public Const SW_RESTORE = 9
Public Const SW_SHOW = 5
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOWNORMAL = 1

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                                     (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
                                      ByVal lpParameters As String, ByVal lpDirectory As String, _
                                      ByVal nShowCmd As Long) As Long

Public Sub ExecuteFile(sFileName As String, sAction As String)
    Dim vReturn               As Long
    'sAction can be either "Open" or "Print".

    If ShellExecute(Access.hWndAccessApp, sAction, sFileName, vbNullString, "", SW_SHOWNORMAL) < 33 Then
        DoCmd.Beep
        MsgBox "File not found."
    End If
End Sub


The reason why I like it is because you don't need to figure anything out about what program is the default application... It will use whatever the user has configured as their preferred application and open or print the file.

One more option for you to ponder!


--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    24th June 2018 - 02:22 AM