View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Value from Registry

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...;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

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Roy Lasris" wrote in message ...
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