Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Read Registry Keys (and possibly write)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Read Registry Keys (and possibly write)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Read Registry Keys (and possibly write)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Read Registry Keys (and possibly write)

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Read Registry Keys (and possibly write)

@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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best Way to Read the Registry? JK Excel Programming 3 October 25th 04 05:55 PM
Retrieving Registry keys Kent Schederin Excel Programming 5 September 3rd 04 04:18 PM
VBA read/write registry nelson Excel Programming 1 August 22nd 03 12:48 PM
VBA read/write registry setting nelson Excel Programming 2 August 22nd 03 07:08 AM
VBA read/write registry setting nelson Excel Programming 0 August 22nd 03 05:41 AM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"