Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / February 2004

Tip: Looking for answers? Try searching our database.

vbscript - How to check if a calendar entry exists?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Long Nguyen - 04 Feb 2004 23:45 GMT
Hi,

In my Outlook custom form I have this vbscript code that get an calendar
item:

   Set olns = Item.Application.GetNameSpace("MAPI")
   Set MyFolder1 = olns.Folders("Public Folders")
   Set MyFolder2 = MyFolder1.Folders("All Public Folders")
   Set MyFolder3 = MyFolder2.Folders("ITS")
   Set MyFolder = MyFolder3.Folders("My Calendar")
   Set olns = Nothing
   Set strCalItem = MyFolder.Items("New request")

If the item "New Request" is not there Outlook would display the message
"Operation failed. An object could not be found."

I'd like to display a meaningful message to users. In vbscript how can I
check if the entry "New Requests" exists in the calendar (and if not display
the meaningful message).

Thanks
Long
Sue Mosher [MVP] - 05 Feb 2004 03:34 GMT
If strCalItem Is Nothing Then
   MsgBox "Operation failed. An object could not be found."
End If
Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hi,
>
[quoted text clipped - 18 lines]
> Thanks
> Long
Long Nguyen - 05 Feb 2004 03:41 GMT
Thanks Sue. But with the code

   Set strCalItem = MyFolder.Items("New Request")
   If strCalItem Is Nothing Then
       MsgBox "Operation failed. An object could not be found."
   End If

Outlook displayed the "Object could not be found" when it execute the Set
strCalItem statement, i.e. BEFORE the If check.

Regards
Long
Sue Mosher [MVP] - 05 Feb 2004 13:14 GMT
Make sure you have an On Error Resume Next statement in the procedure's
declarations section.
Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Thanks Sue. But with the code
>
[quoted text clipped - 8 lines]
> Regards
> Long
Long Nguyen - 06 Feb 2004 04:44 GMT
Thanks Sue. I did miss Hour 19 in your books. :-)

Regards
Long

> Make sure you have an On Error Resume Next statement in the procedure's
> declarations section.
[quoted text clipped - 17 lines]
> > Regards
> > Long
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.