1

I have a VBA file that I've distributed to my coworkers and when my coworkers open Outlook, they get a run-time error 13 on the "Set olRingsInboxItems" line. It works fine on my computer, so I'm at a complete loss.

The following code is ThisOutlookSession:

Option Explicit
Private WithEvents olRingsInboxItems As Outlook.Items
Private Sub Application_Startup()
  Dim oNameSpace As NameSpace
  Set oNameSpace = Application.GetNamespace("MAPI")
  Set olRingsInboxItems = oNameSpace.Folders("Rings").Folders("Inbox").Items
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Do your colleagues have a store named "Rings"? `oNameSpace` gives your VBA code access to all the stores in your folder pane. When you look at your folder pane, some lines are against the left edge and some are indented. The lines against the left edge are stores which are the files in which Outlook stores your mail items, calendar items, tasks are so on. The indented lines are folders within a store. `oNameSpace.Folders("Rings")` gives access to store "Rings". `oNameSpace.Folders("Rings").Folders("Inbox")` gives access to folder "Inbox" within store "Rings". – Tony Dallimore Jan 02 '19 at 23:43
  • `oNameSpace.Folders("Rings").Folders("Inbox").Items` gives access to the items within folder "Inbox" within store "Rings". If your colleagues do not have a store names "Rings" or if that store does not contain folder "Inbox", they will get an error. – Tony Dallimore Jan 02 '19 at 23:45
  • It is possible to access folders by index number, for example: oNameSpace.Folders(1) or oNameSpace.Folders(inx). This allows you to use a For-Loop to search down the list of stores for one with the required name. Would this solve your problem? – Tony Dallimore Jan 02 '19 at 23:51
  • @TonyDallimore Yes, all of my colleagues have a store "Rings". This is our shared email address for the department. I just tried a For-Loop on one of my colleagues machine and had the same result. We both have the same version of Outlook and I have confirmed that our Trust Center Settings are the same and have even refreshed the references needed by the VBA file. – Nathan Guill Jan 03 '19 at 21:13
  • Try deleting `Dim oNameSpace As NameSpace` and `Set oNameSpace = Application.GetNamespace("MAPI")` and change `Set olRingsInboxItems = ...` to `Set olRingsInboxItems =Session.Folders("Rings").Folders("Inbox").Items` According to the documentation, `NameSpace` and `Session` are the same. However, I never use `NameSpace` because it once gave me a strange error which I fixed by changing to `Session`. I do not remember what that error was. I do not know what else to suggest because I cannot see any other difference from the event code I use. – Tony Dallimore Jan 03 '19 at 22:35
  • See how to setup shared inbox https://stackoverflow.com/a/34871809/4539709 – 0m3r Jan 04 '19 at 00:27
  • @0m3r I do not understand how your comment helps. I do not have access to `GetSharedDefaultFolder` so cannot comment on it. `GetDefaultFolder` doesn't work for me because I have a store per email address and none of those stores is the default. When I had access to shared stores, I always accessed them by name as Nathan is attempting. If you have an explanation for Nathan's code failing, I would like to hear as an aid to my own understanding of Outlook. – Tony Dallimore Jan 04 '19 at 19:57
  • I tried both suggestions without success. They both work on my machine, but not my coworker's. I am truly at a loss as to the reason. Both machines are set up identically as far as software is concerned. The main difference is that his is a desktop and mine is a laptop. That shouldn't have any effect on accessing a shared email address as far as I'm aware. – Nathan Guill Jan 07 '19 at 15:32
  • Which office are you using? – 0m3r Jan 07 '19 at 21:45
  • Office 365 ProPlus using Outlook 2016 – Nathan Guill Jan 07 '19 at 22:05

0 Answers0