Discussion:
VBA Macro that Runs nightly to export folder
(too old to reply)
gkn
2010-04-29 21:07:23 UTC
Permalink
Hi there,

I was wondering if you can give me any information on how I can do
this. I am not familiar with VBA programming but have written simple
excel macros in the past. I am not sure how to begin or what the best
resources on the web to do the following task.

Every night, I would like to export all contents of a single folder
"XXX" into a single .csv file and then move the contents to another
folder named xxxx_mmddyy .

Any ideas?
Michael Bauer [MVP - Outlook]
2010-04-30 07:42:48 UTC
Permalink
In principle that's possible with VBA, but it depends on that Outlook is
running, of course.

This example demonstrates how to use a reminder to start a VBA procedure:

http://www.vboffice.net/sample.html?mnu=2&lang=en&smp=10&cmd=showitem

In order to export the content of a folder, loop through its Items
collection. See the object browser (f2) for what properties are available
for the various item types. For instance, an email is represented by the
MailItem object.

As you want to move the items out of the collection, loop backwards through
it, like this:

For i=Items.Count To 1 Step-1
Set Item(Items(i)
' save the content
' eventuall move the item, where Folder is a variable to another folder
Item.Move Folder
Next

Also see the GetDefaultFolder function for how to set a variable to one of
the default folders. For instance, once you have set a variable to the
inbox, this would return a subfolder of the inbox:

Set Folder=Inbox.Folders("whatever")
--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>
Post by gkn
Hi there,
I was wondering if you can give me any information on how I can do
this. I am not familiar with VBA programming but have written simple
excel macros in the past. I am not sure how to begin or what the best
resources on the web to do the following task.
Every night, I would like to export all contents of a single folder
"XXX" into a single .csv file and then move the contents to another
folder named xxxx_mmddyy .
Any ideas?
gkn
2010-04-30 15:11:29 UTC
Permalink
Thank you for the reply. How do we know which version of outlook runs
thi? I have Office Outlook 2007 SP2 MSO (part of office professional
plus 2007)
Michael Bauer [MVP - Outlook]
2010-05-03 07:11:49 UTC
Permalink
See the Application.Version property.
--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>
Post by gkn
Thank you for the reply. How do we know which version of outlook runs
thi? I have Office Outlook 2007 SP2 MSO (part of office professional
plus 2007)
Loading...