• Reading registry keys from VBA (WinXP / Office2003 NL)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Reading registry keys from VBA (WinXP / Office2003 NL)

    Author
    Topic
    #420027

    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. 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?

    Viewing 4 reply threads
    Author
    Replies
    • #949981

      Here is some. STolen from I forgot where

    • #949982

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

      Alan

    • #949983

      A relatively simple way is (using an arbitrary example)

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

    • #949988

      Try System.PrivateProfileString:

      Sub ReadReg()
      MsgBox System.PrivateProfileString("", _
               "HKEY_CURRENT_USERSoftwareGoogleGmailFlags", _
               "browser") ' --> "firefox.exe"
      End Sub
      

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

      • #950118

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

    • #950145

      This post 480341 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.0CommonOpen Findplaces and uses its results to enhance the File Open dialogue. It seems to work (notwithstanding the usual Windows limitations of 10 entries maximum ), but my code is not as readable as that of Kenneth Ives (post 483072). Let me know if you’d like to spend part of the weekend wading through it. It is a work-in-progress.

      • #950361

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

    Viewing 4 reply threads
    Reply To: Reading registry keys from VBA (WinXP / Office2003 NL)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: