Add to calendar when button is clicked - InfoPath Dev
in

InfoPath Dev

Add to calendar when button is clicked

Last post 06-28-2010 05:05 PM by Hilary Stoupa. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-28-2010 12:33 AM

    • sanvir
    • Top 500 Contributor
      Male
    • Joined on 03-03-2010
    • South Africa
    • Posts 30

    Add to calendar when button is clicked

     Hi,

    I have created a leave form for a client. I would like to know how to add an event to the managers calendar if the form is approved and the "add to calendar button is clicked.
    I am struggling with the visual basic coding. This is what i currently have in the button just to test the form:

     Public Sub ADDtoCAL_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                Dim objOutlook As Object
                Dim itmAppt As Object

                objOutlook = CreateObject("Outlook.Application", "Technical")

                itmAppt = objOutlook.CreateItem(1)

                itmAppt.Subject = "Test"
                itmAppt.Start = "06/06/2010 4:15pm"
                itmAppt.Duration = 60
                itmAppt.AllDayEvent = False
                itmAppt.ReminderSet = True
                itmAppt.ReminderMinutesBeforeStart = 5
                itmAppt.Save()
            End Sub

    when i click on the button, it does not do anything.
    any help will be appreciated!

    Thank you.

  • 06-28-2010 01:33 AM In reply to

    • sanvir
    • Top 500 Contributor
      Male
    • Joined on 03-03-2010
    • South Africa
    • Posts 30

    Re: Add to calendar when button is clicked

     Ok i have got the form to add the Test event to the calendar!

    i am having trouble with "itmSubject" > i would like it to select the name that is put into the text box (/my:myfields/my:name) ( im not sure if this is the proper source)

    i would like to do the same with the dates. this is what i currently have:

                Dim objOutlook As Object
                Dim itmappt As Object
                Dim name1 As String
                Dim date1 As Date
                Dim date2 As Date

                name1 = ("/my:myfields/my:name")
                date1 = ("/my:myFields/my:field4")
                date2 = ("/my:myFields/my:field5")

                objOutlook = Microsoft.VisualBasic.CreateObject("Outlook.Application")
                itmAppt = objOutlook.CreateItem(1)

                itmappt.Subject = "Leave for " + name1
                itmappt.Start = "28/06/2010"
                'itmappt.Duration =
                itmappt.end = "30/06/2010"
                itmAppt.AllDayEvent = False
                itmAppt.ReminderSet = True
                itmAppt.ReminderMinutesBeforeStart = 5
                itmAppt.Save()
            End Sub

     

    btw, i am using visual basic

  • 06-28-2010 05:05 PM In reply to

    Re: Add to calendar when button is clicked

    From your original template in your first post, the XPath to the Name field is: /my:myFields/my:Name. It looks like you have your date field XPaths correct, but you may want to rename those fields eventually. Field4 isn't very descriptive and may cause you annoyances later on.

    So, to get the value of your name field:

    name1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Name", NamespaceManager).Value 

    For your dates, I think you'll need to declare those as strings, get the values from the fields, then parse those values to a datetime data type, at which point you should be able to get the difference for the duration.

    Hilary Stoupa

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.