Need 'Like' in here? Where does it need to go?

robyholmes

Registered User.
Local time
Today, 14:55
Joined
Mar 2, 2009
Messages
57
I want to delete all appointments in my calendar with * in the subject. This code (Just a small bit of it) deletes the subjects when strFindAppt = Subject, but I need to find appointments with * in them, not * as the subject without anything else.

strFindAppt = strFindAppt

' Use this method ONLY if the subject of the
' Appointment Item is known and is UNIQUE.
strFindAppt = "*"
Set mobjOLA = CreateObject("Outlook.Application")
Set mobjNS = mobjOLA.GetNamespace("MAPI")
mobjNS.Logon , , False, False
Set mobjFLDR = mobjNS.GetDefaultFolder(olFolderCalendar)
On Error Resume Next
Set mobjAPPT = mobjFLDR.Items(strFindAppt)
If Err.Number <> 0 Then GoTo CannotFindObject
mobjAPPT.Delete
 
Sorry I took so long to reply, been a bit busy.

So looking at that, there is the 'InStr' and 'LIKE'

I need to apply it to a variable I think, as it is used here like this,
Set mobjAPPT = mobjFLDR.Items(strFindAppt)
So how could I make this line search of 'Containing' and not 'Match'?
 
I agree you probably need to introduce a variable that you can apply a conditional to.

I'm not familiar with Outlook object properties, but I'd try to put a control structure around it -- in order to run through all the appointments in code and test for your "contains" condition :

For i = 0 to (number of appointments - 1)
strApptItem = mobjFLDR.Items(i) '?may need to reference a "Name" property
If InStr(1, strApptItem, "*") > 0 And Len(strApptItem) > 1 Then​
'Perform the necessary action to the appointment
End if
Next i

Hope that helps?
 
Last edited:
Don't get you there?

I mean you can see the code at the top.
 
Apologies if I'm missing something, but isn't the Outlook appointment object (what you're calling "mobjAPPT", or the "mobjFLDR" object) capable of returning the Subject string?

If so, assign it to a string variable, then test that variable to see if "*" is in there. Make sense?

granted, this approach seems to be opposite of what you're trying to do -- seems you're assigning the variable beforehand (i.e., strFindAppt = "*") then feeding that into your 'Items' list to hunt for it

----> I'm saying pull all the values from your 'Items' list into your code by looping through them, assigning them to a variable, then testing that variable

Again, if I'm off base, anyone feel free to jump in here . . . but without being familiar with the Outlook object and properties, I'd see that as a straightforward way of accomplishing what you want . . .
 
That seems fine. I see where you are going. I to no nothing about outlook objects, so...

I will have to look around for that code. Or if any one on here knows of it?
 

Users who are viewing this thread

Back
Top Bottom