V.B.A. + Registry

last_user

New member
Hello to everyone!

I would like your opinion about a very weird issue I have. I wrote a V.B.A. script that writes directly in the registry adding a new key (HKEY_CURRENT_USER\Software\ [New Key]). As an xlsm file everything running perfectly, as a standalone exe file (using the trial version of XLS Padlock) I didn’t receive any error, but I didn’t see also the new key in the registry!
Is there any suggestion on how may I write a V.B.A. script to write in the registry and then see the new entry (Key, Value, …etc.) when I will open “regedit.exe”?

Thank you in advance for your attention!
 
Dear sirs,
I experience the same issue. It looks like I cannot correctly write to registry by VBA script when using a compiled Excel by 2019.1.
In details, I get no error messages but the registry key only exists inside “Excel” executable context. When I close the executable, I cannot find the key in the registry.

If I use 2018 version, all works fine.

Here my code:

Function RegKeyRead(i_RegKey As String) As String
Dim myWS As Object
On Error Resume Next
Set myWS = CreateObject(“WScript.Shell”)
RegKeyRead = myWS.RegRead(i_RegKey)
End Function

MsgBox (RegKeyRead(“HKEY_CURRENT_USER\SOFTWARE\MyKey\MySubKey\LastOpenedCLXFolder”))

Thank you for checking,
Fil
 
Thanks for the code, but it’s for reading a key. What code did you use to write to the registry key?
 
Sorry for the mistake. Here is the code for writing the reg key.

'sets the registry key i_RegKey to the
'value i_Value with type i_Type
'if i_Type is omitted, the value will be saved as string
'if i_RegKey wasn’t found, a new registry key will be created
’ REG_SZ - A string. If the type is not specified, this will be used as Default.
’ REG_DWORD - A 32-bit number.
’ REG_EXPAND_SZ - A string that contains unexpanded references to environment variables.
’ REG_BINARY - Binary data in any form. You really shouldn’t touch such entries.
Sub RegKeySave(i_RegKey As String, _
i_Value As String, _
Optional i_Type As String = “REG_SZ”)
Dim myWS As Object
Set myWS = CreateObject(“WScript.Shell”)
myWS.RegWrite i_RegKey, i_Value, i_Type
End Sub

RegKeySave(“HKEY_CURRENT_USER\SOFTWARE\MyKey\MySubKey\LastOpenedCLXFolder”, “c:\temp”)

I run the compiled Excel as administrator, as UAC is off on my side.

Fil
 
Unfortunately, due to other legacy applications I need to run in my environment, I need to keep UAC off. Could you find and fix the issue?

Thank you,
Fil
 
Back
Top