Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all.
I've had a quick search & "google" for vba code to read (and maybe write) to registry keys. I know there is a GetSetting / SaveSetting function for specific keys, but I'm hoping to be able to read other registry key information (mainly application paths). I suppose this can be achieved by a COM call - but would appreciate any tutorials / guides / info. For the sake of argument, reading the "path" of "excel.exe" in current apps for any demo code. TIA |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is a start...
http://support.microsoft.com/kb/145679/en-us#top "How To Use the Registry API to Save and Retrieve Setting" Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "Mike Iacovou" wrote in message ... Hi all. I've had a quick search & "google" for vba code to read (and maybe write) to registry keys. I know there is a GetSetting / SaveSetting function for specific keys, but I'm hoping to be able to read other registry key information (mainly application paths). I suppose this can be achieved by a COM call - but would appreciate any tutorials / guides / info. For the sake of argument, reading the "path" of "excel.exe" in current apps for any demo code. TIA |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here are two approaches other than using Windows API functions.
For the examples, these would return the default value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\App Paths\excel.exe First, Dim wsh strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \" _ & "CurrentVersion\App Paths\excel.exe\" Set wsh = CreateObject("WScript.Shell") MsgBox wsh.RegRead(strKeyPath) of if you're on WinMe/XP/2k or beyond (WMI is installed on the PC), you could use Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=imper sonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe" strValueName = "" oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValu e MsgBox strValue Using WMI gives you more flexibility when reading multiple subkeys or values but the "WScript.Shell" option would be available on more machines. You can also write new values or amend existing ones. Steve "Mike Iacovou" wrote in message ... Hi all. I've had a quick search & "google" for vba code to read (and maybe write) to registry keys. I know there is a GetSetting / SaveSetting function for specific keys, but I'm hoping to be able to read other registry key information (mainly application paths). I suppose this can be achieved by a COM call - but would appreciate any tutorials / guides / info. For the sake of argument, reading the "path" of "excel.exe" in current apps for any demo code. TIA |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See
http://www.rondebruin.nl/register.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Mike Iacovou" wrote in message ... Hi all. I've had a quick search & "google" for vba code to read (and maybe write) to registry keys. I know there is a GetSetting / SaveSetting function for specific keys, but I'm hoping to be able to read other registry key information (mainly application paths). I suppose this can be achieved by a COM call - but would appreciate any tutorials / guides / info. For the sake of argument, reading the "path" of "excel.exe" in current apps for any demo code. TIA |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
@Jim & Steve - many thanks.
@Ron - thanks as ever. The WSH method is simple - but I am not sure if this is present on Win95/NT systems - and the vbapp is running on these :( I opted to modify the API call example you referenced - and it works nicely ( i assumed that this will be compatible across the whole windows family) thanks again to all. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Best Way to Read the Registry? | Excel Programming | |||
Retrieving Registry keys | Excel Programming | |||
VBA read/write registry | Excel Programming | |||
VBA read/write registry setting | Excel Programming | |||
VBA read/write registry setting | Excel Programming |