
March 23rd 06, 12:52 AM
posted to microsoft.public.outlook.program_vba
|
|
Is ElseIf the right expression here?
thank you so much Michael!!!! one last question - thisoutlooksession is
corrupted I think as OL2003 will not open - is there a way to clear
thisoutlooksession of all code so I can at least open OL2003?
"Michael Bauer" wrote:
Am Tue, 21 Mar 2006 15:33:29 -0800 schrieb fionamac:
This sample gets the first lines, starting with a hyphen and ampersand, and
it extracts all the body that follows after these lines. The values are
being stored in the variables NextSubject, NextAction and NextBody.
You can write these variables now into the object´s properties.
Insert this between line 10 and 20:
Dim posAnf as Long
Dim posEnd as Long
Dim NextSubject as String
Dim NextAction as String
Dim NextBody as String
And this between 150 and 160:
' look for the next subject
posAnf=Instr(pobjItem.Body, "- ")
If posAnf Then
posAnf=posAnf+2
' look if it´s the last row
posEnd=Instr(posAnf, pobjItem, vbCRLF)
If posEnd Then
NextSubject = Mid(pobjItem.Body, posAnf, posEnd-posAnf)
' If the next row starts with an @ then it belongs to the former row
posAnf=posEnd+2
If mid(pobjItem.Body, posAnf, 1) = "@" Then
' Find the row´s end and the next action
posAnf=posAnf+1
posEnd=Instr(posAnf, pobjItem.Body, vbCRLF)
If posEnd Then
NextAction=Mid(pobjItem.Body, posAnf, posEnd-posAnf)
Else
NextAction=Mid(pobjItem.Body, posAnf)
Endif
Endif
Else
NextSubject=Mid(pobjItem.Body, posAnf)
Endif
' Get the body without the first two lines (maybe for the next task)
If posEnd Then
NextBody=Mid(pobjItem.Body, posEnd+2)
Endif
Endif
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --
I'm very new to this but I have found a fabulous macro - for managing my
tasks - with user defined fields of "project" and 'next action'. I would
like
some guidance to add a function and I was wondering if you could please
tell
me what expression to use?
Basically in the body of a task - with a user defined field called
'Project'
The trigger for the "Next Steps" macro is a "- " lead ahead of each
action, with one action per line.
A task to trigger the "Next Steps" code would look like this:
Project: project name
Subject: First Task
Notes/Body field looks like this
- Second Task
- Third Task
- Fourth Task
- Fifth Task
...etc
so by completing the task with the ' Subject: First Task' then action 2
leaves the task body and gets put into the subject field.
For me I sort by 'action' so all the @calls are together when I am at a
phone etc
to do this I include a context under each next action
- call Jane for Luke's email
@calls
- email Luke to set up a time to meet
@computer
- draft up notes for the meeting
@computer
...etc
when the next "-" task moves up from body to subject how do I move the "@"
Action below it move to the the user defined 'Action' Field and move the
next
"-" up to the first line of the task body???
here is the macro
' Module : ThisOutlookSession
' Description:
' Procedures : Application_Startup()
' objTaskItems_ItemChange(ByVal pobjItem As Object)
' Modified :
' 11/13/03 WHK
'
' --------------------------------------------------
Private WithEvents objTaskItems As Items
Private Sub Application_Startup()
'TVCodeTools ErrorEnablerStart
On Error GoTo PROC_ERR
'TVCodeTools ErrorEnablerEnd
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set objTaskItems = objNS.GetDefaultFolder(olFolderTasks).Items
'TVCodeTools ErrorHandlerStart
PROC_EXIT:
Exit Sub
PROC_ERR:
Call LogError(Err.Number, Err.Description, "Application_Startup", Erl,
"ThisOutlookSession")
Resume PROC_EXIT
'TVCodeTools ErrorHandlerEnd
End Sub
Private Sub objTaskItems_ItemChange(ByVal pobjItem As Object)
'TVCodeTools ErrorEnablerStart
10 On Error GoTo PROC_ERR
'TVCodeTools ErrorEnablerEnd
Dim objApp As Outlook.Application
Dim objNewTask As TaskItem
Dim intAns As Integer
Dim strSubject As String
Dim strProject As String
Dim objProperty As UserProperty
20 Set objApp = CreateObject("Outlook.Application")
30 If GetSetting(appname:="GTDPolice", section:="Settings",
key:="Enable", Default:=0) = 1 Then
' Start NetCentrics Addin code
40 Set objProperty = pobjItem.UserProperties.Find("Project")
50 If Not objProperty Is Nothing Then
60 strSubject = pobjItem.Subject
70 strProject = pobjItem.UserProperties("Project")
80 If Not pobjItem.UserProperties("Project") = "" Then
90 If pobjItem.Status = 2 Then
100 intAns = MsgBox("You have completed a
Project-related
Task." & vbCrLf & "Task: " & strSubject & vbCrLf & "Project: " &
strProject
& vbCrLf & "Do you want to create a new Next Action for the Project?", 36,
"Next Action?")
110 If intAns = 6 Then
120 Set objNewTask = objApp.CreateItem(olTaskItem)
130 With objNewTask
140 objNewTask.UserProperties.Add("Project",
olText) = strProject 'Item.UserProperties("Project")
150
objNewTask.UserProperties.Add("GettingThingsDone", olYesNo) = 1
'objNewTask.Subject = "[" &
Item.UserProperties("Project") & "]"
160 objNewTask.Display
170 End With
180 End If
190 End If
200 End If
210 End If
220 End If
230 Set objApp = Nothing
240 Set objNewTask = Nothing
250 Set objProperty = Nothing
260 Set pobjItem = Nothing
'TVCodeTools ErrorHandlerStart
PROC_EXIT:
270 Exit Sub
PROC_ERR:
280 Call LogError(Err.Number, Err.Description,
"objTaskItems_ItemChange", Erl, "ThisOutlookSession")
290 Resume PROC_EXIT
'TVCodeTools ErrorHandlerEnd
End Sub
|