Outlook VBA CreateObject fails during Application_Startup()
up vote
0
down vote
favorite
I wrote a macro in Outlook that opens an Excel file, then runs another macro inside the Excel spreadsheet. The Excel macro in turn saves some charts as PDF files, and opens up Outlook to email them as attachments.
When I run this macro with Outlook already open, it works fine. However, if I assign the macro to execute in the Application_Startup event upon startup, I get an error in the Excel macro that says ActiveX cannot create the desired object. It appears on the first line of this code:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
I did Dim both variables as Objects. Sorry for the novice question, but I have been unable to find the explanation with several hours of searching.
Why does this only occur when the macro runs during startup? Does this have something to do with Excel or Outlook not being fully loaded at the time the macro attempts to run?
outlook startup createobject
add a comment |
up vote
0
down vote
favorite
I wrote a macro in Outlook that opens an Excel file, then runs another macro inside the Excel spreadsheet. The Excel macro in turn saves some charts as PDF files, and opens up Outlook to email them as attachments.
When I run this macro with Outlook already open, it works fine. However, if I assign the macro to execute in the Application_Startup event upon startup, I get an error in the Excel macro that says ActiveX cannot create the desired object. It appears on the first line of this code:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
I did Dim both variables as Objects. Sorry for the novice question, but I have been unable to find the explanation with several hours of searching.
Why does this only occur when the macro runs during startup? Does this have something to do with Excel or Outlook not being fully loaded at the time the macro attempts to run?
outlook startup createobject
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I wrote a macro in Outlook that opens an Excel file, then runs another macro inside the Excel spreadsheet. The Excel macro in turn saves some charts as PDF files, and opens up Outlook to email them as attachments.
When I run this macro with Outlook already open, it works fine. However, if I assign the macro to execute in the Application_Startup event upon startup, I get an error in the Excel macro that says ActiveX cannot create the desired object. It appears on the first line of this code:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
I did Dim both variables as Objects. Sorry for the novice question, but I have been unable to find the explanation with several hours of searching.
Why does this only occur when the macro runs during startup? Does this have something to do with Excel or Outlook not being fully loaded at the time the macro attempts to run?
outlook startup createobject
I wrote a macro in Outlook that opens an Excel file, then runs another macro inside the Excel spreadsheet. The Excel macro in turn saves some charts as PDF files, and opens up Outlook to email them as attachments.
When I run this macro with Outlook already open, it works fine. However, if I assign the macro to execute in the Application_Startup event upon startup, I get an error in the Excel macro that says ActiveX cannot create the desired object. It appears on the first line of this code:
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
I did Dim both variables as Objects. Sorry for the novice question, but I have been unable to find the explanation with several hours of searching.
Why does this only occur when the macro runs during startup? Does this have something to do with Excel or Outlook not being fully loaded at the time the macro attempts to run?
outlook startup createobject
outlook startup createobject
edited Nov 9 at 19:19
asked Nov 9 at 19:06
Greg
72
72
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55
add a comment |
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
First thing I'd try is to re-register the server component by running Outlook from the command line with the /RegServer switch.
Secondly, I would check the Launch/Activation settings for Microsoft Outlook component using the dcomcnfg windows utility. (Right-click Start, Run > dcomcnfg, expand Component Services, expand My Computer, expand DCOM Config, location Microsoft Outlook in list, right-click > Properties, Security tab.
Here is a link to a Microsoft support page which may be relevant to your problem...
You receive run-time error 429 when you automate Office applications
If you can provide an error number and version of Office, and whether your machine is part of an AD Domain, it may be easier to get to the source of your problem!
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
add a comment |
up vote
0
down vote
I had a similar problem not long ago.
You are better off starting this whole process from the excel end, and not open excel from outlook.
So open excel, save the charts to pdf AND THEN open outlook from your excel macro to send the email. No outlook macros involved.
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
add a comment |
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%2f53231888%2foutlook-vba-createobject-fails-during-application-startup%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
First thing I'd try is to re-register the server component by running Outlook from the command line with the /RegServer switch.
Secondly, I would check the Launch/Activation settings for Microsoft Outlook component using the dcomcnfg windows utility. (Right-click Start, Run > dcomcnfg, expand Component Services, expand My Computer, expand DCOM Config, location Microsoft Outlook in list, right-click > Properties, Security tab.
Here is a link to a Microsoft support page which may be relevant to your problem...
You receive run-time error 429 when you automate Office applications
If you can provide an error number and version of Office, and whether your machine is part of an AD Domain, it may be easier to get to the source of your problem!
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
add a comment |
up vote
0
down vote
accepted
First thing I'd try is to re-register the server component by running Outlook from the command line with the /RegServer switch.
Secondly, I would check the Launch/Activation settings for Microsoft Outlook component using the dcomcnfg windows utility. (Right-click Start, Run > dcomcnfg, expand Component Services, expand My Computer, expand DCOM Config, location Microsoft Outlook in list, right-click > Properties, Security tab.
Here is a link to a Microsoft support page which may be relevant to your problem...
You receive run-time error 429 when you automate Office applications
If you can provide an error number and version of Office, and whether your machine is part of an AD Domain, it may be easier to get to the source of your problem!
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
First thing I'd try is to re-register the server component by running Outlook from the command line with the /RegServer switch.
Secondly, I would check the Launch/Activation settings for Microsoft Outlook component using the dcomcnfg windows utility. (Right-click Start, Run > dcomcnfg, expand Component Services, expand My Computer, expand DCOM Config, location Microsoft Outlook in list, right-click > Properties, Security tab.
Here is a link to a Microsoft support page which may be relevant to your problem...
You receive run-time error 429 when you automate Office applications
If you can provide an error number and version of Office, and whether your machine is part of an AD Domain, it may be easier to get to the source of your problem!
First thing I'd try is to re-register the server component by running Outlook from the command line with the /RegServer switch.
Secondly, I would check the Launch/Activation settings for Microsoft Outlook component using the dcomcnfg windows utility. (Right-click Start, Run > dcomcnfg, expand Component Services, expand My Computer, expand DCOM Config, location Microsoft Outlook in list, right-click > Properties, Security tab.
Here is a link to a Microsoft support page which may be relevant to your problem...
You receive run-time error 429 when you automate Office applications
If you can provide an error number and version of Office, and whether your machine is part of an AD Domain, it may be easier to get to the source of your problem!
answered Nov 9 at 19:37
Allumearz
1896
1896
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
add a comment |
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am a complete noob about this subject. Are you suggesting I type the C: file path for outlook.exe on my computer, then append "/RegServer"? If so, I get, "The command line argument is not valid. Verify the switch you are using."
– Greg
Nov 9 at 20:11
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
I am using Office '13, and you have the correct error number. I am not sure if it is part of an AD Domain.
– Greg
Nov 9 at 20:13
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
How about this link... CreateObject Outlook.Application Does Not Work. It seems there is more to it than a simple activation problem.
– Allumearz
Nov 12 at 9:40
add a comment |
up vote
0
down vote
I had a similar problem not long ago.
You are better off starting this whole process from the excel end, and not open excel from outlook.
So open excel, save the charts to pdf AND THEN open outlook from your excel macro to send the email. No outlook macros involved.
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
add a comment |
up vote
0
down vote
I had a similar problem not long ago.
You are better off starting this whole process from the excel end, and not open excel from outlook.
So open excel, save the charts to pdf AND THEN open outlook from your excel macro to send the email. No outlook macros involved.
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
add a comment |
up vote
0
down vote
up vote
0
down vote
I had a similar problem not long ago.
You are better off starting this whole process from the excel end, and not open excel from outlook.
So open excel, save the charts to pdf AND THEN open outlook from your excel macro to send the email. No outlook macros involved.
I had a similar problem not long ago.
You are better off starting this whole process from the excel end, and not open excel from outlook.
So open excel, save the charts to pdf AND THEN open outlook from your excel macro to send the email. No outlook macros involved.
answered Nov 9 at 20:15
Nick
77911031
77911031
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
add a comment |
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
Thanks. This is similar to what I did. I just saved the files using the Excel macro, and sent/attached them using the Outlook macro after the Excel one was finished. This worked, but I am still disappointed that I did not figure out what the problem was. I will look into it again when I have the time. Thanks to both of you for your help.
– Greg
Nov 12 at 17:07
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
@Greg Ok no problem. Please mark it as the accepted answer
– Nick
Nov 12 at 17:55
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53231888%2foutlook-vba-createobject-fails-during-application-startup%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
What is the exact error message?
– Dmitry Streblechenko
Nov 9 at 21:55