Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macro doesn't run in Outlook 2002

Status
Not open for further replies.

diwin

Technical User
Nov 29, 2002
218
CA
I created a very short SubProcedure, below, that ran fine at first. Once Outlook 2002 was closed and re-opened, it doesn't run and I get no error message.

I first wrote in in a new module, Module 1. Then I remmed that and pasted it into ThisOutlookSession and created a new toolbar button to run it. No Go.

What am I missing?

This procedure simply opens a new email message addressed to the currently selected Contact in the Contacts list. I was just about to write a line to check to make sure that the Contacts Explorer was active when it stopped working.

Option Explicit
Public Sub DansNewMessage()

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim myItem As MailItem
Dim myRecipient As Recipient

Set myOlApp = CreateObject("Outlook.Application")
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add(myOlSel.Item(1))
myItem.Display

End Sub


Daniel Dillon
 
As you use the CreateObject function don't use the New keyword when you Dim myOlApp.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the tip.
This is my first foray into Outlook. I have done a couple Access Apps.

Any idea why it up and died?

Daniel Dillon
 
No phantom Outlook.exe in task manager ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Nope.

This is the procedure location...

project.gif



Daniel Dillon
 
To get the Task Manager window : Shift+Ctrl+Esc
Look at the 2nd tab

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ya. there is one instance of outlook.exe.

I simply created a new menu and added an the macro to the menu from the Macro item listed in the Categories list under the Command tab in the Customize dialog. Then I dragged it onto a toolbar too. In each case, I chose an image and C&urrent as the name/hotkey.

Anything else I have to do?
Is my script bad?

Daniel Dillon
 
Ok.

When I try Alt-F8 and try to run the macro, I get...

The macros in this project are disabled. Please refer to the online help or documentation of the host application to deternime how to enaboe macros.

Daniel Dillon
 
menu Tools -> Macro -> Security

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
So, to run this one macro, I have to let down my guard? And then I have to answer that silly question of how long I want to allow macros to be available, and the maximum time is 10 minutes????

The whole point of this macro is to save one or two mouse clicks.

Daniel Dillon
 
Have a look at SelfCert.exe

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I downloaded ExpressClickYes. It works fine for me. Now, is SelfCert.exe any better/different/easier?

Daniel Dillon
 
OK. I just created a selfcert and selected it in VBE under Tools/Digital Certs.

Then, when I close and open Outlook, I enable macros and check "Always trust this source."

Then I exit ExpressclickYes.

Then, with security high, I still get a prompt when I run my macro. Not just one prompt though. Now I have to click "Yes" TWICE. What gives?

I run ExpressclickYes and set it to YES, and no problem, digital cert or not.

Unless I am missing sumpthink here, I don't see the use of selfcert.exe.

Daniel Dillon
 
With selfcert you're able to run your macro code even with high security.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I wasn't able to.
Did I not set it up right?

Daniel Dillon
 
Let me clarify.
With High security, I don't get prompted. It just won't run.
With the cert, now I get the option. But that is not my ultimate goal. I want security to be kept on high and run it without any more mouse clicks. That is what ExpressClick yes does, that the self-digital-cert doesn't.

Daniel Dillon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top