A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Count dates



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 10th 06, 10:09 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 10
Default Count dates

I have Outllok 2003 running on an Exchange server. I don't normally
program VBA in Outlook, only Word or Excel.

Is there a way I could do a little macro to count the messages in a
folder and produce a list of how many messages are present for each
date (like 26 for Aug 10, 33 for Aug 9, 12 for Aug 8, etc)?

  #2  
Old August 10th 06, 03:00 PM posted to microsoft.public.outlook.program_vba
Michael Bednarek
external usenet poster
 
Posts: 28
Default Count dates

On 10 Aug 2006 01:09:36 -0700, stevewy@... wrote in
microsoft.public.outlook.program_vba:

I have Outllok 2003 running on an Exchange server.


I hope you don't mean that. Outlook running on the Exchange Server
is not a good thing.

I don't normally
program VBA in Outlook, only Word or Excel.


The techique below is not very Outlook-specific.

Is there a way I could do a little macro to count the messages in a
folder and produce a list of how many messages are present for each
date (like 26 for Aug 10, 33 for Aug 9, 12 for Aug 8, etc)?


VBA's Dictionary Object springs to mind as an appropriate tool.
Here's some code that should get you started:

Sub CounDates()

Dim fldFolder As MAPIFolder
Dim dctDict As New Scripting.Dictionary
Dim itmMail As MailItem
Dim strDate As String
Dim itmNote As NoteItem
Dim i As Long

Set fldFolder = ActiveExplorer.CurrentFolder
Set dctDict = CreateObject("Scripting.Dictionary")

' This will fail if there are items other than MailItems in the folder
For Each itmMail In fldFolder.Items
strDate = Format(itmMail.ReceivedTime, "YYYY-MMM-DD")
dctDict.Item(strDate) = dctDict.Item(strDate) + 1
Next itmMail

' Saving the results in a NoteItem
Set itmNote = CreateItem(olNoteItem)
itmNote.Body = "Counted " & fldFolder.Items.Count & " mail items for " _
& dctDict.Count & " dates in folder """ & fldFolder.Name & """:" & vbCr
For i = 0 To dctDict.Count - 1
itmNote.Body = vbCr & itmNote.Body & dctDict.Keys(i) & ": " & dctDict.Items(i) & vbCr
Next i
MsgBox "Counted " & fldFolder.Items.Count & " mail items for " _
& dctDict.Count & " dates in folder """ & fldFolder.Name & """.", vbOKOnly + vbInformation, "CountDates"
itmNote.Display

End Sub

--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
  #3  
Old August 10th 06, 03:17 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 10
Default Count dates



I'm getting an error when I run it. The error comes on the line "Dim
dctDict As New Scripting.Dictionary" and says "Compile error: user
defined type not defined".

  #4  
Old August 10th 06, 03:49 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Count dates

Put a reference to the Scripting object in your VBA project references.

And never, ever run Outlook on the Exchange server, it's a bad idea.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
oups.com...


I'm getting an error when I run it. The error comes on the line "Dim
dctDict As New Scripting.Dictionary" and says "Compile error: user
defined type not defined".


  #5  
Old August 10th 06, 04:00 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 10
Default Count dates


Ken Slovak - [MVP - Outlook] wrote:
Put a reference to the Scripting object in your VBA project references.

And never, ever run Outlook on the Exchange server, it's a bad idea.


Well, I don't actually know that it's running *on* the server. I think
maybe the e-mail accounts are stored on there. I leave that to the
techies.

Err... how do I put a reference to the Scripting object in your VBA
project references exactly?

  #6  
Old August 10th 06, 04:12 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Count dates

Tools, References.

Set the reference to Microsoft Scripting Runtime (SCRRUN.DLL).

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


wrote in message
ups.com...

Ken Slovak - [MVP - Outlook] wrote:
Put a reference to the Scripting object in your VBA project references.

And never, ever run Outlook on the Exchange server, it's a bad idea.


Well, I don't actually know that it's running *on* the server. I think
maybe the e-mail accounts are stored on there. I leave that to the
techies.

Err... how do I put a reference to the Scripting object in your VBA
project references exactly?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Should Count Invitees Oscar Trevino Outlook - Calandaring 0 June 20th 06 07:33 PM
Email count mismatched Peretz Stern Outlook - General Queries 0 June 12th 06 06:33 PM
Recurring Days That Count Up Ron Anthony Quinn Outlook - Calandaring 0 May 10th 06 07:37 PM
How can I count how many contacts I have ? How can I count how many contacts I have Outlook - Using Contacts 1 May 4th 06 10:24 PM
count contacts ems@drg Outlook - Using Contacts 1 February 23rd 06 06:54 PM


All times are GMT +1. The time now is 07:06 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.