Can InfoPath (2003 SP1) add an event in Outlook Calendar? - InfoPath Dev
in

InfoPath Dev

Can InfoPath (2003 SP1) add an event in Outlook Calendar?

Last post 11-02-2009 06:43 AM by sheep. 32 replies.
Page 1 of 3 (33 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 07-05-2008 04:59 AM

    Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    I am relatively new to InfoPath (2003 SP1) I have created a few questionnaires which is sent out via outlook 2003 email.  The users submit their results to an access database which is fantastic.

    I am not a programmer but got this InfoPath working very well.  It saved me days of work.

    I used the same process to arrange training over three days with 5 hour slots per day, the users submitted to a similar access database.  One of the users really liked how simple and easy to use the form was and asked if the form could add an event in his Outlook 2003.

    I have been searching the web for days and wondered if anyone can help?

     

    The user will select radio button then submit and somehow his outlook 2003 calendar will add an event, is this possible?

    Many thanks JohnTB

  • 07-05-2008 07:54 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hello and welcome!

    The following VBScript, attached to a button, allowed me to create a test event in my Outlook calendar:

     Dim objOutlook
     Dim itmAppt
     
     Set objOutlook = CreateObject("Outlook.Application") 
     Set itmAppt = objOutlook.CreateItem(1)
        
     itmAppt.Subject = "Test"
     itmAppt.Start = "07/05/08 4:15pm"
     itmAppt.Duration = 60
     itmAppt.AllDayEvent = False
     itmAppt.ReminderSet = True
     itmAppt.ReminderMinutesBeforeStart = 5
     itmAppt.Save

    The lowest block, which begins "itmAppt.Subject" is the section that is setting up the information about the appointment. As you can see, I have simply hard coded the information in. We would want to replace that information with information from your form's fields. Let me know if you need some help with that, okay?

    Hilary Stoupa

  • 07-05-2008 08:15 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    HI Hilary,Thank you so much for your help with this.

    You asked for me to let you know if I need some help with the automation.

    I would be extremely grateful if you could help.

    Many thanks

    JohnTB

     

  • 07-05-2008 09:50 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Sure. To start with, I tested this in IP 2007 -- I don't have 2003 on my machine. So let's make sure the basic code works in IP2003 (can't think of a reason why it wouldn't, but it is always best to start with the basics). First, set your form to use VBScript as the programming language. http://support.microsoft.com/kb/828853 explains this -- it is under Tools/Form Options/Advanced. Next, add a button to your form and double click to open the properties or right-click and select button properties.

    When the properties window opens, select the Edit form code button. This will open the Script Editor. A function handler will have been created for your button that looks like this (the CTRL6_5_ bit will change according to the name of your control):

    Sub CTRL6_5_OnClick(eventObj)
    ' Write your code here
    End Sub

    Where you see "'Write your code here" replace that line with the code sample from my above post. Preview the form, click the button, then check your Outlook Calendar and see if the event called test has been added. If you get any errors, or have trouble following these instructions, let me know. After we know this sample runs correctly, we'll start setting this up to use your form information.

    Hilary Stoupa

  • 07-07-2008 05:58 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

    I get the following error

    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:25
     Dim dateIndex, timeIndex, descriptionIndex, duration, reminderTime;

  • 07-07-2008 07:16 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    That error tells me that your form is using JScript instead of VBScript. You need to change to VBScript, then follow the steps again to attach the code to a button. Directions for changing your language are here: http://support.microsoft.com/kb/828853/en-us?spid=2515&sid=229 . You will have to follow the steps to remove the script from your form template first before InfoPath will let you change languages. Do you have any other script in this form?

    Hilary Stoupa

  • 07-07-2008 09:09 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

     You were correct I have changed to VBA but nw get the following error.

     InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected end of statement
    File:script.vbs
    Line:20
    Dim dateIndex, timeIndex, descriptionIndex, duration, reminderTime  Dim eventDate(), eventTime(), eventDescription(), i  Dim objOutlook  Dim itmAppt

  • 07-07-2008 09:25 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Okay -- you pasted your code into the OnClick event for the button? So it begins with "Sub" and ends with "End Sub" ? So the code block looks like this:

    Sub CTRL5_5_OnClick(eventObj)
     
        Dim objOutlook
        Dim itmAppt
     
        Set objOutlook = CreateObject("Outlook.Application") 
        Set itmAppt = objOutlook.CreateItem(1)
        
        itmAppt.Subject = "Test"
        itmAppt.Start = "07/05/08 4:15pm"
        itmAppt.Duration = 60
        itmAppt.AllDayEvent = False
        itmAppt.ReminderSet = True
        itmAppt.ReminderMinutesBeforeStart = 5
        itmAppt.Save

    End Sub

    The only difference should be the ID of the control. Mine is CTRL5_5. Yours will be different -- you can see the button's ID in its properties.My post above describes how to generate the OnClick function for the button if you need to do that....

    Hilary Stoupa

  • 07-07-2008 12:38 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

     I have added the code, the form funs and updtes the database but not Outlook 2003?

    Am I doing something wrong?

     

     

  • 07-07-2008 12:42 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Sub CTRL34_7_OnClick(eventObj)
        Dim dateIndex, timeIndex, descriptionIndex, duration, reminderTime
        Dim eventDate(), eventTime(), eventDescription(), i
        Dim objOutlook
        Dim itmAppt
     
        Set objOutlook = CreateObject("Outlook.Application")
        Set itmAppt = objOutlook.CreateItem(1)
       
        itmApptSub CTRL34_7_OnClick(eventObj)
        Dim dateIndex, timeIndex, descriptionIndex, duration, reminderTime
        Dim eventDate(), eventTime(), eventDescription(), i
        Dim objOutlook
        Dim itmAppt
     
        Set objOutlook = CreateObject("Outlook.Application")
        Set itmAppt = objOutlook.CreateItem(1)
       
        itmAppt.Subject = "Test"
        itmAppt.Start = "15/07/08"
        itmAppt.Duration = 60
        itmAppt.AllDayEvent = True
        itmAppt.ReminderSet = True
        itmAppt.ReminderMinutesBeforeStart = 5
        itmAppt.Save
    End Sub.Subject = "Test"
        itmAppt.Start = "15/07/08"
        itmAppt.Duration = 60
        itmAppt.AllDayEvent = True
        itmAppt.ReminderSet = True
        itmAppt.ReminderMinutesBeforeStart = 5
        itmAppt.Save
    End Sub

  • 07-07-2008 12:49 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    So, when you click the button connected to the code, it doesn't add an event to your calendar? I see that you pasted in your code -- did you accidentally paste twice? Because your code should look like:

    Sub CTRL34_7_OnClick(eventObj)
        
        Dim objOutlook
        Dim itmAppt
     
        Set objOutlook = CreateObject("Outlook.Application")
        Set itmAppt = objOutlook.CreateItem(1)
       
        itmAppt.Subject = "Test"
        itmAppt.Start = "15/07/08"
        itmAppt.Duration = 60
        itmAppt.AllDayEvent = True
        itmAppt.ReminderSet = True
        itmAppt.ReminderMinutesBeforeStart = 5
        itmAppt.Save

    End Sub

    Hilary Stoupa

  • 07-07-2008 01:23 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Yes sorry pasted twice.

    The rules are working but no errors on the VBA but no event added to my calendar

  • 07-07-2008 01:32 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Is your date format European? Try changing itmAppt.Start = "15/07/08" to something like "07/05/08" and check your calendar for both the 7th of May and the 5th of July.....

    Hilary Stoupa

  • 07-07-2008 02:05 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

    No luck with the date change.

     

    I also have a line of code above what has been posted I thought it was just generic code.

    XDocument.DOM.setProperty "SelectionNamespaces", "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:q=""http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"" xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-06-16T14:19:13"" xmlns:xd=""http://schemas.microsoft.com/office/infopath/2003""" '

  • 07-07-2008 02:36 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Yes, that code is autogenerated and does belong there. Well, let's see. You can add a message box to make sure that when you click your button your function is running. Just add this line:

    MsgBox("hello")

    Above the line beginning "Dim dateIndex " etc. Don't worry about re-publishing your form, just open it up in preview and click the button. Now, while we were just testing this code, I'd intended that you add another button to your form for testing, not use your original submit button -- is that what you did, or did you connect the code to an existing button? If you are willing to email me your form, I'd be happy to take a look at it -- that may be a bit quicker than our current method of troubleshooting... :)

    Hilary Stoupa

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