Value from Registry

R

Roy Lasris

Is there an Excel VBA board? I cannot find it. May I post this here please?
In Word, it is easy to get a registry entry using the following formula:

I have set a value via Word to the registry key:
HKEY_LOCAL_MACHINE\Software\SECTIONNAME", "ENTRYNAME")

How can I read it in Excel? I tried the formula suggested by the Help system
under "Registry" and came up with the following, but it doesn't work:

ValueIs = GetSetting(AppName:="MyApp", Section:= _
"HKEY_LOCAL_MACHINE\Software\SECTIONNAME", key:="ENTRYNAME")

What am I doing wrong?

Thanks,
Roy
 
R

Ron de Bruin

Hi Roy
Is there an Excel VBA board
This is the good one

Try this

HOWTO: Use the Windows Script Host to Read, Write, and Delete Registry Keys
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q244675

I make this one some time back, maybe it is useful for you

Sub GetKeyValue()
Dim Shell As Object
Dim keyname As String
Dim valuename As String
Dim keyvalue As Integer

keyname = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\"
valuename = "Send Mail Immediately"

Set Shell = CreateObject("wscript.shell")

On Error Resume Next
keyvalue = Shell.regread(keyname & valuename)
If Err.Number <> 0 Then
MsgBox "Invalid Registry Entry"
Else
MsgBox keyvalue
End If
End Sub
 
B

Bob Phillips

Roy,

Programming is the VBA board.

Excel VBA also has GetSetting and SaveSetting.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
P

PathSmart

Ron,
Thanks. It worked fine, except since my values were strings and not integers,
I had to change the keyvalue dim to string and the comparison at the bottom to
"" not "0". Thanks for your help.

Roy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top