Free Microsoft Outlook Resources & Whitepapers

Macro to run on Open

I have a macro that will add an attachment to the current Outlook message,
but I can't figure out how to get the macro to run automatically when the
message is opened. The message is a template (.oft). I'm new to Outlook
macros, can anyone help?

Thanks,
Jim


Post your answer or comment

comments powered by Disqus
I have a macro that will add an attachment to the current Outlook message,
but I can't figure out how to get the macro to run automatically when the
message is opened. The message is a template (.oft). I'm new to Outlook
macros, can anyone help?

Thanks,
Jim

This is a question for the programming group in outlook. Below is a macro
that will run from outlook macro (not excel). I don't know how to have
outlook schedule the task (macro) to run weekly.

Sub openexcel()
'Dim wb As excel.workbook

FName = "C:tempbook1.xls"
Set xlApp = Application.CreateObject("Excel.Application")
Set xlbook = xlApp.Workbooks.Open(FName)
xlbook.PrintOut

End Sub

"Stew J" wrote:

I would like to make excel print a sheet on a weekly basis. the sheet is
part of an accounting file and the results are updated daily. I need the
information to be either printed or saved to my desktop for manual printing
later. This needs to be completed every Monday.

Due to outlook space constrain for rules, I am not able to run all the rules
that I have set.

Is it possible to have a work around this? Such as create a macro to run the
rules (automatically on a daily basis or click of a button.....)?

I am having issues when I try to setup the Exchange best practice aanlyzer to run on a scheduled basis.  Its says I am giving the wrong credentials when trying to login.

Here is the error:

Error validating Active Directory Logon credentials.  Please try entering a different set of credentials.

I know that the credentials I am using have admin rights to the domain and to the local computer.  Could someone please tell me what I am doing wrong and how I can fix it.  Thanks

I'm trying to run jetstress on one of our new exchange servers we have built but I can't get it to run. I keep getting the following error:

5/3/2010 4:21:00 PM -- Microsoft Exchange Server Jetstress Core Engine (version: 08.02.0060.000) detected.
5/3/2010 4:21:00 PM -- Windows Server (R) 2008 Enterprise Service Pack 2 (6.0.6002.131072) detected.
5/3/2010 4:21:00 PM -- Microsoft Exchange Server Database Storage Engine (version: 08.02.0176.000) detected.
5/3/2010 4:21:00 PM -- Microsoft Exchange Server Database Storage Engine Performance Library (version: 08.02.0176.000) detected.

5/3/2010 4:21:00 PM -- MSExchange Database or MSExchange Database ==> Instances performance counter category is not registered.

5/3/2010 4:21:00 PM -- Database Storage Engine Performance Library is successfully registered.
5/3/2010 4:21:00 PM -- Database Storage Engine Performance objects and counters are successfully loaded.
5/3/2010 4:21:00 PM -- Advanced Database Storage Engine Performance counters are successfully enabled.
5/3/2010 4:21:00 PM -- This process is required to restart for the changes to take effect.

I have searched the forums and tried all of the suggestions to no avail. I have tried the 4-required ESE files from our test environment as well as the files from our current environment. I am able to get it to run on our test server however it is a VM and therefore not attached to our storage array. I have made sure I am using the 64bit version of Jetstress since we are running exchange 2007 SP2 x64 on Server 2008 x64 not R2.

Hi,

How can I schedule auto archive to run on specific time? My problem is that
I have scheduled auto archive to run once in two weeks. Unfortunately it runs
on Monday mornings when Outlook becomes unresponsive and I have to wait 30-45
minutes before I can start reading emails. It would be great if I can
schedule it to run at lunch time or late in night.

I am currently producing a very simple electronic in/out board for my
company. It works by using a public folder to which are posted the
names of everyone in a particular office. For each user you can select
whether you are in or out, where you are and when you are likely to
return.

I have written a number of VBA macros which can be run by the users to
update their status, the system also automatically marks them as out
when Outlook is closed.

I would like to call the "sign in" macro to run automatically when
outlook starts up, but as there is a delay between outlook starting and
finally connecting to our exchange server (very tempermental
connection) I need to call the sign in macro when the connection has
been established.

Does anyone know how I could call this macro to run at the right time?

I am trying to get WSS 3.0 to run on my home pc with vista os; I have tried
the solution given by bamboosolutions but can't find compitible sharepoint
version to install..!! can someone pls help...

I'm running OL12B2. Under OL11, when reading messages, I would flag
messages for followup, using different colored flags to categorize the
messages, and customizing my toolbars to get me one-click access to
those different flags.

Flag functionality appears to have changed in OL12, and my old colored
flags on the toolbar no longer work.

I'm trying to create macros that reproduce the functionality I lost.
The following macro works when I actually open a message:

Sub Red()
Set insp = Application.ActiveInspector
If Not insp Is Nothing Then
Set objMail = insp.CurrentItem
objMail.Categories = "Red-Category"
objMail.MarkAsTask (4)
End If
End Sub

....but the if loop isn't triggered if I try to run the macro when
viewing a message through the reading pane.

How can I adapt this macro to run when called while viewing a message
from the reading pane?

Thanks.

--
Michael D. Adams -- Windsor, Connecticut -- http://www.triskele.com

Blogs: http://www.triskele.com/actuary (News/commentary)
http://www.triskele.com/highway (Highway features)

Hi,

I'm using a Palm m505 and a macro runs on startup of Outlook 2003. How do I
tell Outlook to allow this macro to run w/o me having to hit OK.

Thanks.

jc

This code is fantastic...thank you.
I was wondering though .. is it possible to get this to run on closing the
current open email.

That is .. move the email to a folder on closing it.
I haven't had any luck with getting this to work.

Regards,
Eddie

"Eric Legault [MVP - Outlook]" wrote:

Okay, now that I know exactly what you want, I've altered the macro to handle
any selected messages in the current folder, and to look for the folder name
that you specify underneath the root of the same store containing your Inbox:

Sub MoveSelectedMessagesToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders("Some Folder Under The Root")
'Assume this is a mail folder

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If

For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

"Jim Johnson - Serenity Consulting" wrote:

Thanks for your help Eric. Your macro doesn't quite do what I want - but it
is very close! I'll use it as a basis when I get around to dusting off my VBA
programming skills.

The destination folder is not under the Inbox, but co-equal in the folder
tree (a minor issue). The other is that I use the preview panel and only
fully open a message when absolutely necessary. I need to run the macro
against the selected message in the current mail folder.

Meanwhile I'll have to use the two step "Move to another folder" then select
the intended folder.

Thanks for trying.

"Eric Legault [MVP - Outlook]" wrote:

If your goal was not to "reinvent" a macro but to have it automatically
created for you, then of course you are out of luck because there is no macro
recorder in Outlook. The only recourse we have is to hand-roll our own
solutions, which isn't terribly difficult with Outlook VBA, and that's where
this newsgroup comes in for assisting people who are having problems taming
the Outlook programming model beast.

I thought you had already begun the process of coding the solution, so I
gave you a quick pointer rather than write the code for you. Regardless,
below is the solution to your issue that I can share with you - it took all
of five minutes. It assumes the destination folder is under your Inbox, but
you can always tweak it for another location.

Sub MoveOpenedMessageToFolder()
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("Some Folder Under The Inbox") 'Assume
this is a mail folder

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveInspector Is Nothing Then
'Require that this procedure be called for an open item
Exit Sub
End If

If Application.ActiveInspector.CurrentItem.Class olMail Then
Exit Sub
End If

Application.ActiveInspector.CurrentItem.Move objFolder

Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

"Jim Johnson - Serenity Consulting" wrote:

Not functionality - there is only one action. You missed the point. The goal
was to NOT reinvent a complete macro - just paste it all in. Your one line
may help me figure out which method is needed, but it sure as heck isn't a
complete macro.

Oh well, thanks anyhow - when I have some extra time I'll re-teach myself VBA.

"Eric Legault [MVP - Outlook]" wrote:

What functionality remains to be added to make the macro complete for you?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

"Jim Johnson - Serenity Consulting" wrote:

Well thanks, but that is only half the answer I was looking for.

I know about the 'Move to Folder' option. It is what I am doing now and
takes twice as much work as I am looking for because you have to both select
the function, then select the destination.

And yes, I am looking to move these items every time to the same folder
using an icon or keyboard shortcut. As for the macro - thanks for the key
piece - but I believe it takes a bit more code to complete the macro.

In every other Office app, I could simply record a function this simple and
be done - but NOT in Outlook. I am capable of hand writing my own VBA
routine, but as I don't routinely do this, it always takes me much longer
than necessary. I was hoping somebody out there had already invented this
wheel and would be willing to share.

"Eric Legault [MVP - Outlook]" wrote:

If you are essentially just moving the message rather than deleting it, would
using the File - Move To Folder... command inside the message (or
right-click the message, Move To Folder... / Edit - Move To Folder... in the
folder view) be sufficient for your needs?

If it is the same folder you are always moving the message to, you can use
the Item.Move(DestinationFolder As MAPIFolder Object) method to move the
message to a previously declared MAPIFolder variable.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/

"Jim Johnson - Serenity Consulting" wrote:

I need a second message 'delete' button that doesn't truly delete a message
but moves it to a specified folder. Has anyone already written an Outlook
2003 macro to do this? (Why Microsoft refuses to put a 'learn' function into
Outlook to jump start macro building is beyond me.)

The reason is that I concurrently manage two on-line 'personalities' for
different employers and do not want the messages from one personality
auto-archived to the other personality's archive files.

I can auto-segregate incoming messages by email account, I can
auto-segregate out-going messages by email account using the Rules Wizard -
but I cannot do this with deleted messages. (for legal reasons, I never
actually delete anything).

Hi There,

We use Outlook 2003 and Exchange Server 2003.

I want to create a macro where a set of Rules are run. They need to be run
on a number of mailboxes. The user has two mailboxes "RSVP" and "Ticketing"
which are secondary to their primary mailbox "Event Assistant". There are 6
rules each for "RSVP" and "Ticketing". I have set the rules up, however when
I want to run each one, I have to select the folder to run it in for each
rule, which is always defaulted to the Inbox. This takes time, and I'd love
to create a macro that does it all in one go.

I haven't been able to find any code to write a macro which gives the
conditions for running rules, can someone please provide some guidance on
this.

Thanks!
Jane

I have written a macro to run a .pps file and would like to know If & How I
can configure Outlook 2003 to automatically run the macro at startup.

t runs fine if Outlook isn't already open but if it is already open, a 2nd outlook starts up and the macro doesn't begin to run-I have a msgbox as the 1st line in my macro just to check. Also, security is low so anything should run. I'm new here so I hope I'm posting this in the correct area-tia

Hi,

I've only just puchased outlook 2007 and managed to move all my mail over
from the old mail client.

The problem is its moved over all the spam emails as well, it seems the old
mail client just hide the spam messages but keept them on the inbox.

So now i have an inbox full of spam.

I've been trying to work out how to make outlook run the spam filters on a
selected folder but i can't find out how to do it anywhere??

So i need to run the junk email filters on emails which are already in my
inbox..

Anyone know how to do this???

Thanks

Given the space constraints for rules & alerts, alot of them have been
disactivated. I have been manually running the rules & alert every morning to
sort my mails.

I am wondering whether it is possible to create a macro to take over the
task, ie. selecting the rules and running it?

Would be grateful if anybody know the answer or solution. Thanks.

I have an application which runs perfectly in my (single user) Outlook 2003.

I run a macro which copies all the attacments and the body of the email to a
disc folder.

At the client's networked workstations, I get a message that macros won't
run (in Outlook 2003).

I've looked at the Microsoft's explanations - phew!!!

I guess that there is some sort of system ban.

Can anyone suggest how I might approach the System Admin. to allow this
single macro to run on some of the network workstations?
I've seen something about "signatures"? Is this a way of getting round a
system block?

TIA
Michael Lewis

Can anyone tell me how to create a macro (to run from a buton on Outlook)
that will do ths same as the following steps from the menu (or at least
achieve the same i.e. an export of the contacts file in mdb format):

File
Import and Export
Next
Export to a File
Next
Microsoft Access 97-2003
Next
Personal Folders
Contacts
Next
Overwrite existing file = yes
Finish

Thanks Lou

As Admin, I want to set up a few rules that run on all employee Inboxes to
forward e-mails received from certain vendors with certain subjects into a
new Inbox that everyone will have access to. Can I set up these rules on the
server so that I do not have to set up, update or change rules on each
person's computer?

I have an application which runs perfectly in my (single user) Outlook 2003.

I run a macro which copies all the attacments and the body of the email to a
disc folder.

At the client's networked workstations, I get a message that macros won't
run (in Outlook 2003).

I've looked at the Microsoft's explanations - phew!!!

I guess that there is some sort of system ban.

Can anyone suggest how I might approach the System Admin. to allow this
single macro to run on some of the network workstations?
I've seen something about "signatures"? Is this a way of getting round a
system block?

TIA
Michael Lewis

Hi to All,

I have Created Application in VB. Now I Want To Create Setup Wizard For
That Application. And To Run on Remote PC. So What Have i to Install on
Remote PC to Run That Application.

I Have To Install Vb on Remote PC or Not. or It Will Run Without Need
of VB.

What Is The requirements To Run VB APllication on Remote PC.

Plz Give Reply

Thanks

Sanjay.

HELP...Please...I am so a newby on the VB stuff.

I am trying to create a macro that will move messages from my Drafts folder
to another folder, based on specific words in the subject line.

For example: In my drafts file, a message with "HEALTH:" would be moved to
a unique folder called "Health Articles".

I would like the macro to run either as i save items intot the draft folder,
or is there a way to also create a menu "button" to run the macro
automatically.

Thanks for the help!

Hello:

Sigh..........I spent the whole day configuring macros to run a program.
When I run each macro through the shortcut that I configured for each one,
they run perfectly.....PERFECTLY!

But, the Windows Server 2008 Task Scheduler does not like something. I need
to use task scheduler unfortunately to run these macros overnight, otherwise
the work that I spent a whole Sunday conducting is worthless.

My guess is that it is the Actions tab of the Basic Task in Windows
Scheduler does not understand the shortcut that runs my macro. Here is the
path for one of the shortcuts:

"C:Program FilesMicrosoft DynamicsGP$DYNGPDynamics.exe" "C:Program
FilesMicrosoft DynamicsGP$DYNGPDynamics.set" "D:GPShareGP MacrosGP
Login_CSI.mac"

So, when it did not work the first time, I split up the shortcut path into
the following: "C:Program FilesMicrosoft DynamicsGP$DYNGPDynamics.exe"

Then, at the same time, I told the Action tab to run this as an additional
argument:
"C:Program FilesMicrosoft DynamicsGP$DYNGPDynamics.set" "D:GPShareGP
MacrosGP Login_CSI.mac"

Finally, I told it to "Start In" here:"C:Program FilesMicrosoft
DynamicsGP$DYNGP"

Still, no success.

Anybody got any ideas? In any case, this is ridiculous. Previous versions
of the Task Scheduler were not nearly this hard to run.

childofthe1980s

I have added tick boxes to word 2007 via delevoper tab and tools.
This function works perfectly.But on opening the document I have to wait at
least 2 minutes for it to load up.Can I do anything to speed it up
thanks
K


Not finding an answer? Try a Google search.