Problem Checking the available stores in my Inbox (Outlook VBA)

su_80 1 Reputation point
2021-01-05T11:49:56.397+00:00

Hello, Triying to use a macro in a shared store in Outlook, I received this error:

"Run-time error '-1698234242 (9ac7007e)' Automation Error.

Then I did a "test" for Check the available stores in my Inbox but stopped in "Next oStore" and I receive this error (similar to the previous):

Run-time error -941162370 (c7e7007e) Automation Error.

Sub Test()
Dim myNameSpace As Outlook.NameSpace
Dim oStore As Outlook.Store
Set myNameSpace = Application.GetNamespace("MAPI")
For Each oStore In myNameSpace.Stores
Debug.Print oStore.DisplayName
Next oStore
End Sub

I don't know where is the problem... I already have Stores in my Inbox. The error is not in the code. Someone for helping me? Thanks in advance.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,489 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
4,887 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tom van Stiphout 1,621 Reputation points MVP
    2021-01-09T20:47:54.227+00:00

    The help page on Store object says you should check using IsOpen before accessing a store. Try that.

    Your simple code works just fine for me.