Outlook VBA Runtime Error 13 when setting variable
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
vba outlook outlook-vba
|
show 5 more comments
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
vba outlook outlook-vba
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 2 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 2 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 2 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 3 at 21:13
Try deletingDim oNameSpace As NameSpace
andSet oNameSpace = Application.GetNamespace("MAPI")
and changeSet olRingsInboxItems = ...
toSet olRingsInboxItems =Session.Folders("Rings").Folders("Inbox").Items
According to the documentation,NameSpace
andSession
are the same. However, I never useNameSpace
because it once gave me a strange error which I fixed by changing toSession
. 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 3 at 22:35
|
show 5 more comments
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
vba outlook outlook-vba
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
vba outlook outlook-vba
vba outlook outlook-vba
edited Jan 4 at 0:24
0m3r
8,02892554
8,02892554
asked Jan 2 at 18:07
Nathan GuillNathan Guill
265
265
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 2 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 2 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 2 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 3 at 21:13
Try deletingDim oNameSpace As NameSpace
andSet oNameSpace = Application.GetNamespace("MAPI")
and changeSet olRingsInboxItems = ...
toSet olRingsInboxItems =Session.Folders("Rings").Folders("Inbox").Items
According to the documentation,NameSpace
andSession
are the same. However, I never useNameSpace
because it once gave me a strange error which I fixed by changing toSession
. 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 3 at 22:35
|
show 5 more comments
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 2 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 2 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 2 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 3 at 21:13
Try deletingDim oNameSpace As NameSpace
andSet oNameSpace = Application.GetNamespace("MAPI")
and changeSet olRingsInboxItems = ...
toSet olRingsInboxItems =Session.Folders("Rings").Folders("Inbox").Items
According to the documentation,NameSpace
andSession
are the same. However, I never useNameSpace
because it once gave me a strange error which I fixed by changing toSession
. 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 3 at 22:35
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 2 at 23:43
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 2 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 2 at 23:45
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 2 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 2 at 23:51
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 2 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 3 at 21:13
@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 3 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 3 at 22:35
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 3 at 22:35
|
show 5 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011124%2foutlook-vba-runtime-error-13-when-setting-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011124%2foutlook-vba-runtime-error-13-when-setting-variable%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 2 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 2 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 2 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 3 at 21:13
Try deleting
Dim oNameSpace As NameSpace
andSet oNameSpace = Application.GetNamespace("MAPI")
and changeSet olRingsInboxItems = ...
toSet olRingsInboxItems =Session.Folders("Rings").Folders("Inbox").Items
According to the documentation,NameSpace
andSession
are the same. However, I never useNameSpace
because it once gave me a strange error which I fixed by changing toSession
. 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 3 at 22:35