Errors when trying to add to outlook calendar using form fields - InfoPath Dev
in

InfoPath Dev

Errors when trying to add to outlook calendar using form fields

Last post 02-16-2012 03:21 AM by socknose. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-15-2012 10:19 AM

    Errors when trying to add to outlook calendar using form fields

    Hi. I've been using this website as a guide for a number of problems and it has proved extremely useful. I'm currently trying to make it so that the user can click on a button and automatically have what they've entered added into their outlook calendar. It all works fine until I start trying to reference the fields on the form. This is what I have currently

    Sub CTRL237_5_OnClick(eventObj)

    Dim objOutlook

    Dim itmAppt

    Dim subj

     Dim datenode

    Set objOutlook = CreateObject("Outlook.Application")

    Set itmAppt = objOutlook.CreateItem(1)

    subj = InputBox("Please enter a subject")

    if subj = "" then exit sub

    set datenode = XDocument.DOM.selectSingleNode("/my:myFields/my:hirecarstartdate")

    itmAppt.Subject = subj

    itmAppt.Start = datenode.text

    itmAppt.Duration = 60 itmAppt.

    AllDayEvent = False

    itmAppt.ReminderSet = True

    itmAppt.ReminderMinutesBeforeStart = 30

    itmAppt.Save

     

    When I try to run that I get the following error.

    Object required: 'datenode'
    File:script.vbs
    Line:38

    When I remove the .text from the end of Line38 I get this:

    The following error occurred:

    Type Mismatch: Unable to coerce parameter value. Outlook cannot translate your string.
    File:script.vbs
    Line:38

    Type mismatch.

    Can anyone help me? I'm close to pulling my hair out and just making the user fill out the fields as well as an input box!

  • 02-16-2012 03:21 AM In reply to

    Re: Errors when trying to add to outlook calendar using form fields

    OK, sorted that now. It was the formatting of the date picker and not having the correct xpath that was at fault. The problem I'm running into now is that this button sits in a repeating field and, when you add another field it only refers to the first incident of the date picker. Can someone explain to me (in very simplistic terms) how I go about referencing repeating fields in VBA? I can't find any decent articles on how to do it online 

    Here is where I am now 

    Sub CTRL254_5_OnClick(eventObj)

    Dim objOutlook Dim itmAppt

    Dim subj

    Dim datenode

    Set objOutlook = CreateObject("Outlook.Application")

    Set itmAppt = objOutlook.CreateItem(1)

    subj = InputBox("Please enter a subject")

    if subj = "" then exit sub

    set datenode = XDocument.DOM.selectSingleNode("my:myFields/my:carelement/my:hirecarelement/my:Hirecar/my:hirecarstartdate")

    itmAppt.Subject = subj

    itmAppt.Start = datenode.text

    itmAppt.Duration = 60 itm

    Appt.AllDayEvent = False

    itmAppt.ReminderSet = True

    itmAppt.ReminderMinutesBeforeStart = 30

    itmAppt.Save

    End Sub

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