Results 1 to 8 of 8
  1. #1
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading registry keys from VBA (WinXP / Office2003 NL)

    In a VBA project I need to search a registry key and its subkeys for a particular filename. That file is put in a folder by a document management system ( Documentum). This key is not in HKEY_CURRENT_USERSoftwareVB and VBA Program Settings, so I cannot use the built-in VBA registry functions like GetSetting.
    I searched the VB/VBA forum and found Dylan Morley's <post#=166979>post 166979</post#>. But when I import that into the VBA project, a LOT of code is red, indicating syntax errors. Has anybody got that working in VBA or maybe an alternative?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office2003 NL)

    Here is some. STolen from I forgot where <g>
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office2003 NL)

    Without knowing the details, have you considered using the RegRead method, using VBScript with a WshShell object?

    Alan

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reading registry keys from VBA (WinXP / Office2003 NL)

    A relatively simple way is (using an arbitrary example)

    Dim var
    var = CreateObject("WScript.Shell").RegRead("HKCUControl PanelColorsMenu")

  5. #5
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office

    Try System.PrivateProfileString:
    <pre>Sub ReadReg()
    MsgBox System.PrivateProfileString("", _
    "HKEY_CURRENT_USERSoftwareGoogleGmailFlags", _
    "browser") ' --> "firefox.exe"
    End Sub
    </pre>

    If you leave the FileName argument blank, VBA looks in the Registry.

  6. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office

    Thanks guys for all the suggestions. I'll look into them.

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office

    This <post#=480341>post 480341</post#> was the tail end of my latest foray into trawling the system registry. In particular, the little application examines keys in the region of HKEY_CURRENT_USERSoftwareMicrosoftOffice10.0Common Open Findplaces and uses its results to enhance the File Open dialogue. It seems to work (notwithstanding the usual Windows limitations of 10 entries maximum and be damned), but my code is not as readable as that of Kenneth Ives (<post#=483072>post 483072</post#>). Let me know if you'd like to spend part of the weekend wading through it. It is a work-in-progress.

  8. #8
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading registry keys from VBA (WinXP / Office

    Thanks Chris.
    But I didn't wade through it this weekend. I was too busy partying; my sister in law turned 50...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •