Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'd like to automated the editing of Event Subjects in Outlook Calenda

Status
Not open for further replies.

ajaeger

Technical User
Feb 6, 2003
201
US
I integrated a product that pulls in the daily weather forcast and places it in Outlook as an all day event. The subject of this event reads "Alexandria - Monday: Intermittent Clouds; Hi 77 F ; Lo 56" It's too long. I want to edit the Subject so that it only prints everything to the right of the colon. Is there a way to do this with a keystroke macro (ie, putting the cursor at the left side of the field and holding Ctrl+Shift, then hitting the right arrow 4 times, then hitting the Delete key, then Save.) Or using functions to identify length of the field, the location of the colon, and return the all characters to the right of it. The events to update can be identified since they all start with "Alexandria - Monday: ", "Alexandria - Tuesday: ", "Alexandria - Wednesday: ", etc... I'd want this macro to run against all future weather forcast Calendar Events (they are pulled into Outlook 5 days out from the current date).

My question is more to do with how to do coding for the a Calendar Event, ie, how to query/update the Subject, date (to check if 5 days out). I can figure out how to parse out the text that I need.

Thanks!

Anna Jaeger
iMIS Database Support
 
hi,

I'd suggest Googling [highlight]Outlook, VBA[/highlight].

For instance, I found
You will have to do the research and some of the heavy lifting. Post the code that you are trying and you will get help here.

If you want to have code served up to you, you'll need to hire a programmer. But we will help you develop YOUR code that YOU provide.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



OK, I relent. Paste this code into a module in Outlook and run ChangeCalendarSubject...
Code:
Option Explicit

' Declare global Outlook Application and NameSpace variables.
' These are declared as global variables so that they need not
' be re-created for each procedure that uses them.
Public golApp          As Outlook.Application
Public gnspNameSpace   As Outlook.Namespace

Function InitializeOutlook() As Boolean
   ' This function is used to initialize the global Application and
   ' NameSpace variables.
   
   On Error GoTo Init_Err
   
   Set golApp = New Outlook.Application    ' Application object.
   Set gnspNameSpace = golApp.GetNamespace("MAPI") ' Namespace object.
   
   InitializeOutlook = True

Init_End:
   Exit Function
Init_Err:
   InitializeOutlook = False
   Resume Init_End
End Function

Sub ChangeCalendarSubject()
 
    Dim fld As Outlook.MAPIFolder
    Dim itm As Object
    Dim MyCal As Outlook.MailItem
    Dim int_cnt As Integer, a, sSubject As String
    '-----------
    
    On Error Resume Next

    ' Use the InitializeOutlook procedure to initialize global
    ' Application and NameSpace object variables, if necessary.
    If golApp Is Nothing Then
       If InitializeOutlook = False Then
          MsgBox "Unable to initialize Outlook Application " _
             & "or NameSpace object variables!"
          Exit Sub
       End If
    End If
    
    Set golApp = New Outlook.Application
    
    Set itm = gnspNameSpace.GetDefaultFolder(olFolderCalendar)
    
    For int_cnt = 1 To itm.Items.Count
        sSubject = itm.Items(int_cnt)
        If Left(sSubject, 10) = "Alexandria" Then
            Debug.Print int_cnt, sSubject
            a = Split(sSubject, ":")
            itm.Items(int_cnt).Subject = a(1)
        End If
    Next
    
    Set fld = Nothing
    Set itm = Nothing
    Set MyCal = Nothing

End Sub




Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I just Googled some sites and was reading up. Will read some more, go thru your code to understand it then give it a whirl. Thanks :)

Anna Jaeger
iMIS Database Support
 


Good for you!

Post back with any questions.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top