Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6984757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:35:27+00:00 2026-05-27T18:35:27+00:00

I have the following piece of VB code to get the registry subkey (

  • 0

I have the following piece of VB code to get the registry subkey (NOT the key or the value of a registry). I just need to list out applications in Microsoft subkey (e.g. Office, Notepad, Keyboard etc.).

It worked in VB.NET but I’m trying to apply the same code to VBA in Macro, I get a run time error saying "Object variable or With block variable not set" on the line of GetOBject and EmumKey. I though the following code should be compatible for both VB.NET and VBA.
Can anyone please explain?

Dim temp As Object
'On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001
temp = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\default:StdRegProv")

Dim rPath As String
rPath = "Software\Microsoft\IdentityCRL\UserExtendedProperties"

Dim arrSubKeys(5) As Object
temp.EnumKey(HKEY_CURRENT_USER, rPath, arrSubKeys)

For Each ask In arrSubKeys
    MsgBox(ask.ToString)
Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:35:28+00:00Added an answer on May 27, 2026 at 6:35 pm

    For VBA try it like this

    • temp is an object and needs to be used with Set
    • the temp.Enum syntax is temp.EnumKey HKEY_CURRENT_USER, rPath, arrSubKeys not temp.EnumKey(HKEY_CURRENT_USER, rPath, arrSubKeys)
    • Dim your variables at the top of your code for neatness 🙂

    This code lists all the folders under HKEY_CURRENT_USER\Software\Microsoft\ to the Immediate window of the VBE

    Const HKEY_CURRENT_USER = &H80000001
    Sub TestME()
        Dim temp As Object
        Dim strComputer As String
        Dim rPath As String
        Dim arrSubKeys()
        Dim strAsk
    
        strComputer = "."
        Set temp = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
    
        rPath = "Software\Microsoft\"
        temp.EnumKey HKEY_CURRENT_USER, rPath, arrSubKeys
        For Each strAsk In arrSubKeys
            Debug.Print strAsk
        Next
    End Sub
    

    example output

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following piece of code: public List<myTask> MyTask { get; set; }
I have a doubt i use the following piece of code get data from
I have the following piece of code: private String toString(List<DrugStrength> aDrugStrengthList) { StringBuilder str
i have the following piece of code : package com.example.task; import java.util.List; import android.os.Bundle;
I have the following piece of code (only relevant parts): xhttp=new XMLHttpRequest(); xhttp.open(GET,doc_name,false); xhttp.send();
I have the following piece of code: $item['price'] = 0; /* Code to get
I have the following piece of code, which when I compile it, I get:
I have the following piece of python code. The code is supposed to get
I have used the following piece of code to set defailt value of a
I have the following piece of code: public class Test { List<Future> future =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.