Registry Entries via Excel

R

Roy Lasris

Is there an Excel VBA board? I cannot find it. May I post this here please?

In Word, it is easy to get a registry value using the following formula:

NameIs = System.PrivateProfileString("", _
"HKEY_LOCAL_MACHINE\Software\SECTIONNAME", "ENTRYNAME")

The above is not recognized by Excel. This is a formula that I found when I did
a search under 'registry' in the Excel help system, but it doesn't read the
right information. (Actually, it seems to read nothing and it returns an empty
value.) Any ideas as to what might make this work?

NameIs = GetSetting(AppName:="MyApp", Section:= _
"HKEY_LOCAL_MACHINE\Software\SECTIONNAME", _
key:="ENTRYNAME")

Thanks.

Roy
 
J

Jean-Guy Marcil

Hi Roy,

Try microsoft.public.excel.programming

For your GetSetting question:

GetSetting always looks directly at HKEY_CURRENT_USER\Software\VB and VBA
program settings and no where else, so all you specify is the branch
underneath it:

GetSetting(appname := "ACME Project", section := "Startup", key := "Name",
default:= "Key not found")
This means you have to use SaveSetting to create the entries in the
registry, and then use GetSetting later to retrieve them.

If you want to access other regristry keys you have to use API calls. Do a
Google on Registry API Excel and the likes.

Alternatively, since you seem to be familiar with Word VBA, you could, from
within your Excel code, create a temporary invisible Word document, and use
Word's PrivateProfileString method. It would slow things down a bit, but it
would be easy for you.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top