Here is an example (with some debug info that you can leave out). It is now
restricted to String type entries. You must add the 'Windows Script Host
Object Model' to your references (via Tools => References)
Public Function ReadRegisteryKey(RKey As String) As String
Dim oKey As New IWshShell_Class ' Windows Script Host Object Model
library
Dim RKeyValue As String
Dim RegVal As Variant, Entry As Variant
On Error Resume Next
RegVal = oKey.RegRead(RKey)
If Not RegVal = Empty Then
If TypeName(RegVal) = "String" Then
RKeyValue = RegVal
'Else
' Debug.Print TypeName(RegVal)
' For Each Entry In RegVal
' Debug.Print Entry
' Next
End If
End If
If Err.Number <> 0 Then
'Debug.Print Err.Number & ": " & Err.Description
ReadRegisteryKey = vbNullString
Err.Clear
Else
ReadRegisteryKey = RKeyValue
End If
Set oKey = Nothing
End Function
Public Function WriteRegisteryKey(RKey As String, Value As Variant) As
Boolean
Dim oKey As New IWshShell_Class ' Windows Script Host Object Model
library
Dim RKeyValue As String
Dim RegVal As Variant, Entry As Variant
On Error Resume Next
Call oKey.RegWrite(RKey, Value)
If Err.Number <> 0 Then
'Debug.Print Err.Number & ": " & Err.Description
WriteRegisteryKey = False
Err.Clear
Else
WriteRegisteryKey = True
End If
Set oKey = Nothing
End Function