Powershell com object, infopath.application error "The index is out of bounds." - InfoPath Dev
in

InfoPath Dev

Powershell com object, infopath.application error "The index is out of bounds."

Last post 02-09-2018 07:41 AM by Hilary Stoupa. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 02-07-2018 11:35 AM

    • mrblah
    • Not Ranked
    • Joined on 02-07-2018
    • Posts 5

    Powershell com object, infopath.application error "The index is out of bounds."

     I've been using powershell to dump our infopath forms to PDF for years.   Just updated to windows 10 and now our powershell script is acting up.

     I'm using this command to setup the com object, it's been working for years.   Pasting this into powershell generates the below error on all our machines.

     $infopath = New-Object -com InfoPath.Application -verbose:$false

     The popup says "the index is out of bounds.   Invalid index."   Clicking ok the script continues fine and dumps the views to pdf like always,  but clicking ok 5,000 times, with a 10 second pause per form is getting old quick..

     Anyone have any idea?   I've not found anything on this error and infopath searching around.

  • 02-08-2018 07:48 AM In reply to

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    Can you provide more of your script? I'd be happy to see if the issue repros on my Windows 10 machine & see if I can help you troubleshoot it. :)
    Hilary Stoupa

  • 02-08-2018 08:07 AM In reply to

    • mrblah
    • Not Ranked
    • Joined on 02-07-2018
    • Posts 5

    Re: Powershell com object, infopath.application error "The index is out of bounds."

     This one does an open & save, I use it to handle form updates with on load rules that run once.  Worked fine in windows 7, in 10 I get the popup error. 

     

    Param($Path = "c:\temp\xml\",[switch]$verbose)

    Write-Host

    function Invoke-FormPrint
    {
        Param($InfoForm)
        $shortname = $InfoForm.name
        Write-Verbose "   – FormPrint: Creating COM Object"
        $infopath = New-Object -com InfoPath.Application -verbose:$false
        Write-Verbose "   – FormPrint: Calling Open(`$InfoForm.fullname,10)"
        $infopath.XDocuments.Open($InfoForm.fullname,10) | out-null
        Write-verbose "   – FormPrint: Calling PrintOut()"
        $infopath.XDocuments[0].save()
        sleep 3
        Write-verbose "   – FormPrint: Calling Quit()"
        $infopath.quit()
        if(!$?)
        {
            Write-Host "    - Error printing Form: $shortname" -fore RED
        }
        else
        {
            Write-Host "    - Successfully printed Form: $shortname" -fore Green
        }
    }

    $erroractionpreference = "silentlycontinue"

    if($verbose){$verbosepreference="continue";$erroractionpreference="continue"}

    Write-Verbose " + Processing all Forms from: $path"
    $Forms = dir $path "*.xml"

    Write-Verbose "  + $($Forms.count) Forms found"
    Write-host " + Processing all $($Forms.count) Forms located at: $path" -fore White

    foreach($Form in $Forms)
    {
        Write-Host "  + saving Form: $($Form.Name)" -fore White
        Invoke-FormPrint $Form
    }
     

  • 02-08-2018 10:42 AM In reply to

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    So - just tried this with a simple form I created (it had one field). I opened the form, filled it out, saved the XML. I ran the script, changing it to the folder I'd saved the XML in - no issue at all. If you just manually open one of the XML in c:\temp\xml, does it open w/out issue?
    Hilary Stoupa

  • 02-08-2018 11:15 AM In reply to

    • mrblah
    • Not Ranked
    • Joined on 02-07-2018
    • Posts 5

    Re: Powershell com object, infopath.application error "The index is out of bounds."

     I can manually open forms fine,  the script has worked for me for years, this is the first time I've tried to run it on windows 10,  I'm in popup hell, ohh and they popunder too just to make it more fun.

     

    If I do not click OK within 20-30 seconds the code continues and the form it was on will not process at all it'll move on to the next one and repeat the cycle

     

     


     

  • 02-08-2018 02:06 PM In reply to

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    Where is the XSN the XMLs used published to?
    Hilary Stoupa

  • 02-08-2018 03:24 PM In reply to

    • mrblah
    • Not Ranked
    • Joined on 02-07-2018
    • Posts 5

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    I get the error launching the infopath com object, not on the open command
  • 02-08-2018 04:50 PM In reply to

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    Oh, I see - it doesn't matter what the XSN is, you have the same issue. Silly question, what version of InfoPath / Office are you using? I've got 32 bit on my current machine, but my old laptop has 64 bit.... are you using 64?
    Hilary Stoupa

  • 02-08-2018 05:09 PM In reply to

    • mrblah
    • Not Ranked
    • Joined on 02-07-2018
    • Posts 5

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    win 10 64bit, with 32bit office/infopath
  • 02-09-2018 07:41 AM In reply to

    Re: Powershell com object, infopath.application error "The index is out of bounds."

    Wow - I'm at a loss. You've tried this on more than one machine, same results on all? On mine, with my test form, I don't have the issue at all. Attaching a screenshot w/ version numbers just in case it is helpful.
    Hilary Stoupa

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