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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to have a macro run open of outlook

Status
Not open for further replies.

aheu9

Programmer
Sep 7, 2006
17
US
I want a macro to run when outlook is opened. How can this be done???'
Thanks for any help in advance
 
Hi aheu9! Try this from Outlook help:
Code:
Remarks
An Outlook Visual Basic for Applications (VBA) macro can use this event procedure to initialize itself when Outlook starts.

Example
This Microsoft Outlook Visual Basic for Applications example displays a welcome message to the user and maximizes the Outlook explorer window when Outlook starts.

Private Sub Application_Startup()
	MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser
	Application.ActiveExplorer.WindowState = olMaximized
End Sub

Tom

Born once die twice; born twice die once.
 
I created the macro however it is not running. My macro security is set to medium and I am enabling them upon startup. I tried setting the security to low and still no luck. Does the fact that the subroutine i named "Application_Startup" make it run on startup or what specifically determines if it is run on startup??
Thanks,
aheu9
 
Not sure why it's not running. Here's how I set mine up (which worked):

1. Launch Outlook.
2. Set your security to Medium or Low (sounds like you did.)
3. Press Alt + F11 on your keyboard
4. If you do not see a module when the Visual Basic editor launches:
*Expand the folder labeled Microsoft Outlook Objects in the Project Explorer Window.
*Double click ThisOutlookSession
5. If the module is blank:
*click the Object dropdown at the top of the module window (it reads General)
*Select Application
*Select Startup from the Procedure dropdown (it reads Item Send)

You should now have a code window like this:
Code:
[COLOR=blue]Private Sub[/color] Application_ItemSend([COLOR=blue]ByVal[/color] Item [COLOR=blue]As Object[/color], Cancel [COLOR=blue]As Boolean[/color])

[COLOR=blue]End Sub[/color][COLOR=gray]
_____________________________________________________________________[/color]
[COLOR=blue]Private Sub [/color]Application_Startup()
[COLOR=blue]
End Sub[/color]

Write your code in the Application_Startup() routine.

You may have the module in the wrong location?

Not sure, but hope this helps.

Tom


Born once die twice; born twice die once.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top