Help for writing an Outlook 2007 macro

Status
Not open for further replies.
L

LGM

Hello .... I was wondering if someone could assist me in writing a macro for

Outlook 2007 that would file contacts with previously assigned categories

into subfolders that have the same name as those categories. For example, if

a contact had a category designation of "Restaurants" the macro would file

it in a subfolder called "Restaurants"

Also, if a contact did not have any category listed for it, then it would be

filed in a folder called "Unfiled"

I would also like to be able to assign this script/macro to a one-button and

put it in a taskbar or menu in Outlook.

Can someone help? I am a TOTAL newbie to scripts so I need explicit

instructions.

Thanks in advance.

--LGM
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Do you want to learn VBA and write the code yourself? Then start with the

object browser (f2), which helps you to get familiar with the object model

of Outlook.

Best regards

Michael Bauer

Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:


> Hello .... I was wondering if someone could assist me in writing a macro


for
> Outlook 2007 that would file contacts with previously assigned categories
> into subfolders that have the same name as those categories. For example,


if
> a contact had a category designation of "Restaurants" the macro would


file
> it in a subfolder called "Restaurants"

> Also, if a contact did not have any category listed for it, then it would


be
> filed in a folder called "Unfiled"

> I would also like to be able to assign this script/macro to a one-button


and
> put it in a taskbar or menu in Outlook.

> Can someone help? I am a TOTAL newbie to scripts so I need explicit
> instructions.

> Thanks in advance.

> --LGM
 
L

LGM

Michael,

Thanks for you reply but I don't understand it. I hit F2 while Outlook is

open and nothing happens.

Do you mean to open up the windows that says "VBAProject.OTM [design]" at

the top? If so, I did that but I don't know where to begin.

Either someone needs to point me to an easy-to-understand tutorial on the

subject of writing these macros or get me started by posting some code.

--LGM

"Michael Bauer " wrote:



> Do you want to learn VBA and write the code yourself? Then start with the
> object browser (f2), which helps you to get familiar with the object model
> of Outlook.

> > Best regards
> Michael Bauer
>

>

> Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:
>
> > Hello .... I was wondering if someone could assist me in writing a macro

> for
> > Outlook 2007 that would file contacts with previously assigned categories
> > into subfolders that have the same name as those categories. For example,

> if
> > a contact had a category designation of "Restaurants" the macro would

> file
> > it in a subfolder called "Restaurants"
> > Also, if a contact did not have any category listed for it, then it would

> be
> > filed in a folder called "Unfiled"
> > I would also like to be able to assign this script/macro to a one-button

> and
> > put it in a taskbar or menu in Outlook.
> > Can someone help? I am a TOTAL newbie to scripts so I need explicit
> > instructions.
> > Thanks in advance.
> > --LGM

> .
>
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
First open the VBA editor (alt+f11), then the object browser (f2). Switch

from <All Libraries> to Outlook. If you select any object left hand or an

object's property or function right hand and press f1, you'll get help and

often a code sample, too.

A function that can be called from a toolbar button must be declared like

this:

Public Sub Whatever()

' your code here

End Sub

The item selected in a folder can be accessed through the Selection

colllection of the active Explorer object. The active Explorer is accessible

via Application.ActiveExplorer.

So, these are your first keywords to look into the object browser for more

help: ActiveExplorer, and Selection.

The category of an item is stored in its Categories property.

If you want to file the items in Outlook (as opposed to the Windows file

system), see the MapiFolder object. Each MapiFolder object has a Folders

collection for its subfolders, and an Add function for creating a new

subfolder.

To start with one folder, you might call GetDefaultFolder(olFolderInbox),

which returns the default Inbox.

Best regards

Michael Bauer

Am Wed, 16 Dec 2009 10:45:02 -0800 schrieb LGM:


> Michael,

> Thanks for you reply but I don't understand it. I hit F2 while Outlook is
> open and nothing happens.

> Do you mean to open up the windows that says "VBAProject.OTM [design]" at
> the top? If so, I did that but I don't know where to begin.

> Either someone needs to point me to an easy-to-understand tutorial on the
> subject of writing these macros or get me started by posting some code.

> --LGM

> "Michael Bauer " wrote:
>
>

>
>> Do you want to learn VBA and write the code yourself? Then start with the
> > object browser (f2), which helps you to get familiar with the object


model
> > of Outlook.
>

>> > > Best regards
> > Michael Bauer
> >

> >

>
>
>> Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:
> >
> >> Hello .... I was wondering if someone could assist me in writing a macro

> > for
> >> Outlook 2007 that would file contacts with previously assigned


categories
> >> into subfolders that have the same name as those categories. For


example,
> > if
> >> a contact had a category designation of "Restaurants" the macro would

> > file
> >> it in a subfolder called "Restaurants"
> >
>>> Also, if a contact did not have any category listed for it, then it


would
> > be
> >> filed in a folder called "Unfiled"
> >
>>> I would also like to be able to assign this script/macro to a one-button

> > and
> >> put it in a taskbar or menu in Outlook.
> >
>>> Can someone help? I am a TOTAL newbie to scripts so I need explicit
> >> instructions.
> >
>>> Thanks in advance.
> >
>>> --LGM

> > .
> >
 
L

LGM

This is way over my head. Thanks anyway. I'll just do without it.

"Michael Bauer " wrote:



> First open the VBA editor (alt+f11), then the object browser (f2). Switch
> from <All Libraries> to Outlook. If you select any object left hand or an
> object's property or function right hand and press f1, you'll get help and
> often a code sample, too.

> A function that can be called from a toolbar button must be declared like
> this:

> Public Sub Whatever()
> ' your code here
> End Sub

> The item selected in a folder can be accessed through the Selection
> colllection of the active Explorer object. The active Explorer is accessible
> via Application.ActiveExplorer.

> So, these are your first keywords to look into the object browser for more
> help: ActiveExplorer, and Selection.

> The category of an item is stored in its Categories property.

> If you want to file the items in Outlook (as opposed to the Windows file
> system), see the MapiFolder object. Each MapiFolder object has a Folders
> collection for its subfolders, and an Add function for creating a new
> subfolder.

> To start with one folder, you might call GetDefaultFolder(olFolderInbox),
> which returns the default Inbox.

> > Best regards
> Michael Bauer
>

>

> Am Wed, 16 Dec 2009 10:45:02 -0800 schrieb LGM:
>
> > Michael,
> > Thanks for you reply but I don't understand it. I hit F2 while Outlook is
> > open and nothing happens.
> > Do you mean to open up the windows that says "VBAProject.OTM [design]" at
> > the top? If so, I did that but I don't know where to begin.
> > Either someone needs to point me to an easy-to-understand tutorial on the
> > subject of writing these macros or get me started by posting some code.
> > --LGM
> > "Michael Bauer " wrote:
> >
> >
> >
> >> Do you want to learn VBA and write the code yourself? Then start with the
> >> object browser (f2), which helps you to get familiar with the object

> model
> >> of Outlook.
> >
> >> > >> Best regards
> >> Michael Bauer
> >>

> >>

> >
> >
> >> Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:
> >
> >>> Hello .... I was wondering if someone could assist me in writing a macro
> >> for
> >>> Outlook 2007 that would file contacts with previously assigned

> categories
> >>> into subfolders that have the same name as those categories. For

> example,
> >> if
> >>> a contact had a category designation of "Restaurants" the macro would
> >> file
> >>> it in a subfolder called "Restaurants"
> >>
> >>> Also, if a contact did not have any category listed for it, then it

> would
> >> be
> >>> filed in a folder called "Unfiled"
> >>
> >>> I would also like to be able to assign this script/macro to a one-button
> >> and
> >>> put it in a taskbar or menu in Outlook.
> >>
> >>> Can someone help? I am a TOTAL newbie to scripts so I need explicit
> >>> instructions.
> >>
> >>> Thanks in advance.
> >>
> >>> --LGM
> >> .
> >>

> .
>
 

Mike T

Member
Hi, Michael (or anyone else interested) -




This is over my head, too, but I'd like to continue the thread briefly if you don't mind. I've swiped some code, I mean, done a little VBA programming in Word and am new to Outlook 2007 and its object model. I'm trying to re-create a function that I first used in T'bird to keep my mailbox size down, back when we had a 15MB limit. Can you advise me how or where to get started with it?




In T'bird, I used the tags feature to mark email as it came in - red for 'ToDo', etc., and gray for 'ToDelete'. Flagging a message as 'ToDelete' moved it to a separate folder; and that folder was configured to permanently delete anything over X days old. This way, I could clear messages out of my Inbox with a single keystroke but hold onto them for a few weeks longer, just in case.




So what I think I want to do is to write a macro to move messages categorized as 'ToDelete' to another folder, then set the archive settings to permanently delete those of a certain age. I'm guessing that would be easier than to archive only the old messages in that category in the Inbox. (I have a Search Folder to filter for my 'ToDelete' messages but can't archive those.




Sorry to keep running on. Thanks for any insight you can offer.








This is way over my head. Thanks anyway. I'll just do without it.






"Michael Bauer " wrote:




>

>

> First open the VBA editor (alt+f11), then the object browser (f2). Switch

> from <All Libraries> to Outlook. If you select any object left hand or an

> object's property or function right hand and press f1, you'll get help and

> often a code sample, too.

>

> .... [abbreviated quote]

> >> Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:

> >>

> >>> Hello .... I was wondering if someone could assist me in writing a macro

> >> for

> >>> Outlook 2007 that would file contacts with previously assigned
[/color]

> categories

> >>> into subfolders that have the same name as those categories. For


> example,

> >> if

> >>> a contact had a category designation of "Restaurants" the macro would

> >> file

> >>> it in a subfolder called "Restaurants"

> >>>

> >>> Also, if a contact did not have any category listed for it, then it


> would

> >> be

> >>> filed in a folder called "Unfiled"

> >>>

> >>> I would also like to be able to assign this script/macro to a one-button

> >> and

> >>> put it in a taskbar or menu in Outlook.

> >>>

> >>> Can someone help? I am a TOTAL newbie to scripts so I need explicit

> >>> instructions.

> >>>

> >>> Thanks in advance.

> >>>

> >>> --LGM

> >> .

> >>


> .

> [/color]
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Why don't you just delete the message, which moves it with a single click

into the Deleted Items folder? For that folder you can use the archive

setting to clean messages older than x days.

Best regards

Michael Bauer

Am Tue, 22 Dec 2009 10:41:49 -0500 schrieb Mike T:


> Hi, Michael (or anyone else interested) -

> This is over my head, too, but I'd like to continue the thread briefly
> if you don't mind. I've swiped some code, I mean, done a little VBA
> programming in Word and am new to Outlook 2007 and its object model. I'm
> trying to re-create a function that I first used in T'bird to keep my
> mailbox size down, back when we had a 15MB limit. Can you advise me how
> or where to get started with it?

> In T'bird, I used the tags feature to mark email as it came in - red
> for 'ToDo', etc., and gray for 'ToDelete'. Flagging a message as
> 'ToDelete' moved it to a separate folder; and that folder was configured
> to permanently delete anything over X days old. This way, I could clear
> messages out of my Inbox with a single keystroke but hold onto them for
> a few weeks longer, just in case.

> So what I think I want to do is to write a macro to move messages
> categorized as 'ToDelete' to another folder, then set the archive
> settings to permanently delete those of a certain age. I'm guessing that
> would be easier than to archive only the old messages in that category
> in the Inbox. (I have a Search Folder to filter for my 'ToDelete'
> messages but can't archive those.

> Sorry to keep running on. Thanks for any insight you can offer.

> LGM;108049 Wrote:
> > This is way over my head. Thanks anyway. I'll just do without it.
>

>
>> "Michael Bauer " wrote:
> >
> >
>>
>>> First open the VBA editor (alt+f11), then the object browser (f2).

> > Switch
> >> from <All Libraries> to Outlook. If you select any object left hand

> > or an
> >> object's property or function right hand and press f1, you'll get

> > help and
> >> often a code sample, too.
> >
>>> .... -[abbreviated quote]-
> >> >> Am Tue, 15 Dec 2009 10:46:01 -0800 schrieb LGM:
> >> >
>>> >>> Hello .... I was wondering if someone could assist me in writing

> > a macro
> >> >> for
> >> >>> Outlook 2007 that would file contacts with previously

> > assigned

> >> categories
> >> >>> into subfolders that have the same name as those categories. For
> >> example,
> >> >> if
> >> >>> a contact had a category designation of "Restaurants" the macro

> > would
> >> >> file
> >> >>> it in a subfolder called "Restaurants"
> >> >>
>>> >>> Also, if a contact did not have any category listed for it, then

> > it
> >> would
> >> >> be
> >> >>> filed in a folder called "Unfiled"
> >> >>
>>> >>> I would also like to be able to assign this script/macro to a

> > one-button
> >> >> and
> >> >>> put it in a taskbar or menu in Outlook.
> >> >>
>>> >>> Can someone help? I am a TOTAL newbie to scripts so I need

> > explicit
> >> >>> instructions.
> >> >>
>>> >>> Thanks in advance.
> >> >>
>>> >>> --LGM
> >> >> .
> >> >
>>> .
> >>
[/color][/color]
 

Mike T

Member
Yours is a perfectly reasonable approach, but where's the fun in that?!? I'm a tinkerer by nature and I guess my real aim is to use this 'problem' as an excuse to re-learn some VBA. It's been years since I wrote anything on my own, and I've forgotten most of what I knew or fallen behind. So I'm looking for good reference materials (in print or online) and other sources of info I can use to learn more of the science and the art of it. Thanks again for your insight. - Mike T




Why don't you just delete the message, which moves it with a single click


into the Deleted Items folder? For that folder you can use the archive


setting to clean messages older than x days.




--


Best regards


Michael Bauer




>






Am Tue, 22 Dec 2009 10:41:49 -0500 schrieb Mike T:




> Hi, Michael (or anyone else interested) -

>

> This is over my head, too, but I'd like to continue the thread briefly

> if you don't mind. I've swiped some code, I mean, done a little VBA

> programming in Word and am new to Outlook 2007 and its object model. I'm

> trying to re-create a function that I first used in T'bird to keep my

> mailbox size down, back when we had a 15MB limit. Can you advise me how

> or where to get started with it?

>

> In T'bird, I used the tags feature to mark email as it came in - red

> for 'ToDo', etc., and gray for 'ToDelete'. Flagging a message as

> 'ToDelete' moved it to a separate folder; and that folder was configured

> to permanently delete anything over X days old. This way, I could clear

> messages out of my Inbox with a single keystroke but hold onto them for

> a few weeks longer, just in case.

>

> So what I think I want to do is to write a macro to move messages

> categorized as 'ToDelete' to another folder, then set the archive

> settings to permanently delete those of a certain age. I'm guessing that

> would be easier than to archive only the old messages in that category

> in the Inbox. (I have a Search Folder to filter for my 'ToDelete'

> messages but can't archive those.

>

> Sorry to keep running on. Thanks for any insight you can offer.

>

>

>

> LGM;108049 Wrote:

> > This is way over my head. Thanks anyway. I'll just do without it.

> >

> >


[rest of thread deleted to save space]
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
e_a_g_l_e_p_i Has nobody used Office 2021 enough to help me or have you given up on me.......lol Using Outlook 1
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
L Help connecting to hosted exchange server 2016 Using Outlook 0
B Seeking help with Outlook rule Using Outlook 2
D Need help with MS Authenticator Using Outlook 4
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
S.Champ Please help? I've imported a random workcalendar I dont even know who's. Can I undo it? and then I need to re-sync the google one again. Its a mess:( Using Outlook 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
F Microsoft Outlook Connector 14.0.6123.5001 - Help! Using Outlook 6
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
E Outlook 2010 need help with rules Using Outlook 0
B HELP! Using Outlook 4
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
M Winmail. dat - HELP Using Outlook 2
Diane Poremsky Help! My Contacts are being updated! Using Outlook 0
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3
J Can Anyone Help?? Outlook VBA and Custom Forms 1
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
B Need Help - Willing to pay Outlook VBA and Custom Forms 10

Similar threads

Top