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
Go to the top of the page
 
HairyBob
post Feb 27 2018, 05:44 AM
Post#2



Posts: 992
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: 6,273
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?
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
Go to the top of the page
 
DanielPineault
post Mar 1 2018, 08:35 AM
Post#5


UtterAccess VIP
Posts: 6,273
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!

Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    14th December 2018 - 03:08 PM