How to get value from registry?

A

avkokin

Hello.
Probably I found solution for getting the path for recent files. It
can get from registry. Examle, for Office 2003 it is here:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General
\RecentFiles

I want to get value from this key. How?
I used follow code:
Sub getPathRF()
'get the path for recent files
Dim oPath As String
Dim sPath As String
oPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common
\General\RecentFiles"
sPath = GetSetting() '???? I don't dig ????
MsgBox sPath
End Sub

However I don't know how to get value for my case? Help VBA don't
explain for me.
Thank you very much.
 
J

Jonathan West

avkokin said:
Hello.
Probably I found solution for getting the path for recent files. It
can get from registry. Examle, for Office 2003 it is here:
HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General
\RecentFiles

I want to get value from this key. How?
I used follow code:
Sub getPathRF()
'get the path for recent files
Dim oPath As String
Dim sPath As String
oPath = "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common
\General\RecentFiles"
sPath = GetSetting() '???? I don't dig ????
MsgBox sPath
End Sub

However I don't know how to get value for my case? Help VBA don't
explain for me.
Thank you very much.

The GetSetting and SaveSetting commands only pick up values from a small
corner of the registry. To be able to reliably read from the rest of the
registry, you need to use Windows API functions. Fortunately you don't need
to learn all that stuff yourself, Karl Peterson has very helpfully written
and published code for the purpose. Take a look here

http://vb.mvps.org/samples/project.asp?id=RegSettings
 
A

avkokin

Dear collegues!
I found my solution (below), maybe it will helpful for somebody:
Sub getSpecFolder_new()
Dim myPath As String
Dim objWSH
Dim bKey As String
Set objWSH = CreateObject("WScript.Shell")
bKey = objWSH.RegRead("HKCU\Software\Microsoft\Office\11.0\Common
\General\RecentFiles")
myPath = Environ$("appdata") & "\" & "\Microsoft\Office\" & bKey 'Set
the path.
With Dialogs(wdDialogFileOpen)
.Name = myPath
If .Display = -1 Then
MsgBox .Name
End If
End With
End Sub
 

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