-
VBA write to registry Win 7
I am currently writing to the registry with the following code under Word VBA 2003 running on XP sp3:
Sub RegSave(MyKey as String, MyVal as String, Optional MyType as String = "REG_SZ")
Dim myWS as Object
Set myWS = CreateObject("WScript.Shell")
myWS.RegWrite (MyKey, MyVal, MyType)
End Sub
This works great, if the key does not exist, it is created. If existing, it is updated with the new value.
However,
Running on Win7 I get an error when calling it where the key does not exist. "Invalid root in registry key"
"HKEY_LOCAL_MACHINE\SOFTWARE\abc\def\"
If I manually create the key by accessing the 64 bit registry by typing at the command line: %systemroot%\syswow64\regedit -m and create the key, my RegRead (which is also a windows scripting registry read function) is able to read it.
However, I need to create and update these key from my VBA application.
I have read a lot on the redirection to WOW6432NODE but I cant fit this into actual code.
A billion thanks for help
-
Have you looked at or tried:
SaveSetting and GetSetting?
This pair makes writing and retrieving application data in the registry a walk in the park.
-
Greg,
I am not able to find anything on your site about "SaveSetting"
Mike
-
Sorry for the confusion. There isn't anything on my site about that specifically. These are built-in VBA statements. Just type them in the editor, select, and press F1.
-
Greg,
Looks Very interesting.
I have an outside app that needs to read some of these values.
Just exactly where are the settings located? Under HKLM, HKCU ??
Thanks
-
In the key "VB and VBA Program Settings"
-
OK,
I found it
You are a genius. Now I can write to the registry in Words' native method.
And thanks a zillion to the billionth power
Mike
-
One question,
Is there a way to set the default value?
Thanks
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules