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

Help with Code - Creating Status Report from Task items



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 1st 06, 08:00 PM posted to microsoft.public.outlook.program_vba
Steve
external usenet poster
 
Posts: 3
Default Help with Code - Creating Status Report from Task items

Hi all,

I located the following code from another post within this group. It
does most of what I want but I was wonderering if there is a way to
parse each task and copy on the lines that stat with
*cstart* and ends with *cend*

When I update my task with comments I start the comment with *cstart*
and end it with *cend*

This is needed because several of my task originate from long email
threads and since this is just a high level report I want to capture
the whole body.


Anyone done this before if so care to share your approach?
Thanks
Steve

***Start Code

Sub CreateStatusReport()
Dim objOutlook
Dim objNameSpace
Dim objFolder
Dim MyItems
Dim CurrentTask
Dim strOutput

Const olMailItem = 0
Const olTaskItem = 3
Const olFolderTasks = 13


'Create Outlook, Namespace, Folder Objects and Task Item
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder =
objNameSpace.GetDefaultFolder(olFolderTasks)
Set MyItems = objFolder.Items
dtLastWeek = DateAdd("d", -7, Date)
dtNextWeek = DateAdd("d", 7, Date)
'Loop through all tasks with a Due Date on or before Today.
strOutput = strOutput & "h2Due This Week/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate = dtLastWeek And
CurrentTask.DueDate = Date Then
icount = icount + 1
strOutput = " " & strOutput & "b" & icount & ".
" & CurrentTask.Subject & " ------- " & CurrentTask.PercentComplete &
"% Completed/b"
If CurrentTask.Complete Then
strOutput = strOutput & "-b
ACCOMPLISHMENTS/b-" & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
If Len(CurrentTask.Body) 0 Then
strOutput = " " & strOutput &
"blockquotebNotes: /b" & CurrentTask.Body & "/blockquote" &
vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

strOutput = strOutput & "h2Due Next Week/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate Date And CurrentTask.DueDate
= dtNextWeek Then
icount = icount + 1
strOutput = strOutput & icount & ". " &
CurrentTask.Subject
If CurrentTask.Complete Then
strOutput = strOutput & "-b
ACCOMPLISHMENTS/b-" & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
If Len(CurrentTask.Body) 0 Then
strOutput = strOutput & "blockquotebNotes:
/b" & CurrentTask.Body & "/blockquote" & vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

strOutput = strOutput & "h2Task in Progress/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate = dtNextWeek Then
icount = icount + 1
strOutput = strOutput & icount & ". " &
CurrentTask.Subject
strOutput = strOutput & " Due -b " &
CurrentTask.DueDate & "/b" & vbCrLf
If Len(CurrentTask.Body) 0 Then
strOutput = strOutput & "blockquotebNotes:
/b" & CurrentTask.Body & "/blockquote" & vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

' create new outgoing message
Set objMsg = objOutlook.CreateItem(olMailItem)
objMsg.To = " ' Manager's
Email address here
objMsg.CC = " ' Send Copy of to
myself
objMsg.Subject = "Steve J. Jones Status Report - " & Date
' Change Email subject here
objMsg.Display
strOutput = Replace(strOutput, vbCrLf, "br")
objMsg.HTMLBody = strOutput
'Clean up
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing

Set objMsg = Nothing
End Sub

***End CODE

  #2  
Old August 2nd 06, 05:45 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Help with Code - Creating Status Report from Task items

Am 1 Aug 2006 12:00:24 -0700 schrieb Steve:

You can search for "cstart" with the InStr function. E.g.

Dim pos&
pos=InStr(1, "*cstart*abc*cend*", "*cstart*", vbTextCompare)

That returns a result of 1. Add the length of the searched phrase and
subtract that from the result of searching for *cend*. That gives you the
start position and length of the part between *cstart* and *cend*. You can
extract that part now with the Mid function.

Both functions are also explained in the VBA help.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Hi all,

I located the following code from another post within this group. It
does most of what I want but I was wonderering if there is a way to
parse each task and copy on the lines that stat with
*cstart* and ends with *cend*

When I update my task with comments I start the comment with *cstart*
and end it with *cend*

This is needed because several of my task originate from long email
threads and since this is just a high level report I want to capture
the whole body.


Anyone done this before if so care to share your approach?
Thanks
Steve

***Start Code

Sub CreateStatusReport()
Dim objOutlook
Dim objNameSpace
Dim objFolder
Dim MyItems
Dim CurrentTask
Dim strOutput

Const olMailItem = 0
Const olTaskItem = 3
Const olFolderTasks = 13


'Create Outlook, Namespace, Folder Objects and Task Item
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objFolder =
objNameSpace.GetDefaultFolder(olFolderTasks)
Set MyItems = objFolder.Items
dtLastWeek = DateAdd("d", -7, Date)
dtNextWeek = DateAdd("d", 7, Date)
'Loop through all tasks with a Due Date on or before Today.
strOutput = strOutput & "h2Due This Week/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate = dtLastWeek And
CurrentTask.DueDate = Date Then
icount = icount + 1
strOutput = " " & strOutput & "b" & icount & ".
" & CurrentTask.Subject & " ------- " & CurrentTask.PercentComplete &
"% Completed/b"
If CurrentTask.Complete Then
strOutput = strOutput & "-b
ACCOMPLISHMENTS/b-" & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
If Len(CurrentTask.Body) 0 Then
strOutput = " " & strOutput &
"blockquotebNotes: /b" & CurrentTask.Body & "/blockquote" &
vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

strOutput = strOutput & "h2Due Next Week/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate Date And CurrentTask.DueDate
= dtNextWeek Then
icount = icount + 1
strOutput = strOutput & icount & ". " &
CurrentTask.Subject
If CurrentTask.Complete Then
strOutput = strOutput & "-b
ACCOMPLISHMENTS/b-" & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
If Len(CurrentTask.Body) 0 Then
strOutput = strOutput & "blockquotebNotes:
/b" & CurrentTask.Body & "/blockquote" & vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

strOutput = strOutput & "h2Task in Progress/h2"
icount = 0
For Each CurrentTask In MyItems
If CurrentTask.DueDate = dtNextWeek Then
icount = icount + 1
strOutput = strOutput & icount & ". " &
CurrentTask.Subject
strOutput = strOutput & " Due -b " &
CurrentTask.DueDate & "/b" & vbCrLf
If Len(CurrentTask.Body) 0 Then
strOutput = strOutput & "blockquotebNotes:
/b" & CurrentTask.Body & "/blockquote" & vbCrLf & vbCrLf
Else
strOutput = strOutput & vbCrLf
End If
End If
Next

' create new outgoing message
Set objMsg = objOutlook.CreateItem(olMailItem)
objMsg.To = " ' Manager's
Email address here
objMsg.CC = " ' Send Copy of to
myself
objMsg.Subject = "Steve J. Jones Status Report - " & Date
' Change Email subject here
objMsg.Display
strOutput = Replace(strOutput, vbCrLf, "br")
objMsg.HTMLBody = strOutput
'Clean up
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing

Set objMsg = Nothing
End Sub

***End CODE

 




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
Creating Task sometimes collapses group T. Wise Outlook - General Queries 3 July 14th 06 04:46 AM
Code to set Flag Status to complete on custom form ICT User Outlook - Using Forms 3 March 27th 06 11:59 PM
creating calendar items VERY slow Al Blake Outlook and VBA 1 February 28th 06 01:13 PM
VBA Code to check Task Status [email protected] Outlook and VBA 2 February 3rd 06 06:16 PM
Moving a Mix of Mail Items and Report Items Steve Roberts Outlook and VBA 1 January 24th 06 10:36 PM


All times are GMT +1. The time now is 07:57 PM.


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.