Persistent InfoPath error - InfoPath Dev
in

InfoPath Dev

Persistent InfoPath error

Last post 01-25-2008 12:54 PM by srudolph728. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 01-22-2008 11:13 AM

    Persistent InfoPath error

    Hi all, I'm hoping someone can help with this. I was tasked with creating a way to automatically generate InfoPath documents on the fly, to be stored on a Sharepoint website. I found some code on the web and managed to get it to work correctly as a VB app, but I get the following error message when I run the script (output by the code in a messagebox): "Invalid context for OM call. InfoPath cannot execute any load calls while another load call is in progress". The problem is that I can't get rid of this error  - it pops up when I open any InfoPath document, even on another part of the site. I tried rebooting, removing the VB project from my machine, running the Office repair utility, and even uninstalling and reinstalling InfoPath, all to no avail. The worst part is that I created a new project with the same code but pointing to a different Sharepoint page, and when I run that code, the old code executes instead. It seems pretty clear that the code is still being executed somehow, but I can't figure out how to get rid of it. Does anyone have any suggestions as to what I can do to stop this code from running? Please let me know if I need to post any more information.


    Thanks,

    Steve
     

  • 01-22-2008 02:52 PM In reply to

    Re: Persistent InfoPath error

    Seems to me like a legitimate error message. Have yo utried walking through your code with a debugger? Sounds like you are doing something (probably in the OnLoad / Loading event) which is illegal during that event.

  • 01-23-2008 07:30 AM In reply to

    Re: Persistent InfoPath error

    Hi Greg - other than the error, I think the major issue I'm having is that every time I try to execute code using InfoPath, an older version of this script gets executed instead.

     For example: I originally had this script (call it Script1), which autofilled a text field on a test form with data, let's say "TestText1" in a Sharepoint document library page (Page1). Now, I change the data to "TestText2" and rerun Script1, but it creates a new document with "TestText1" in the field. I comment out the line of code that creates the document, rerun it, and it does the exact same thing, creating a new document with "TextText1" in the form field.

    So, I create a new project (Script2) with the same code but pointing to a completely different document library section of Sharepoint (Page2) using "TestText2" as test data. When I run Script2, I end up with a new document on Page1 with TestText1 in the form, and no document gets created on Page2 at all. So, it would seem that some earlier version of Script1 is somehow getting executed from within InfoPath whenever I execute any script at all from Visual Studio, regardless of any changes I've made. I just can't figure out how to stop this from happening; it seems to be localized to my machine.

  • 01-24-2008 09:51 AM In reply to

    Re: Persistent InfoPath error

    Strange indeed. Have you tried clearing your cache? It could be that a cached version of the form is being loaded instead of the new one.

  • 01-24-2008 10:06 AM In reply to

    Re: Persistent InfoPath error

    I was thinking that as well, but when I go to Start - Programs -  Microsoft Office - Infopath, the 'getting started' screen opens but then the app immediately closes. I think this is because my script is being executed and has a me.close statement in it (I know the script is being executed because a new document is being created).

    I'm considering completely uninstalling Office out of desperation, but I'm not even sure that will fix the problem. Is there any other way to clear the cache?

  • 01-24-2008 07:53 PM In reply to

    Re: Persistent InfoPath error

    If you are seeing Getting Started screen, it wouldn't be failing because of script. You only see the Getting Started when you are opening InfoPath without a form template. Script only executes in form templates. Hence, this is probably just a bad install. Have you tried repairing Office?

    Patrick Halstead
    Project Manager at Qdabra
  • 01-25-2008 07:15 AM In reply to

    Re: Persistent InfoPath error

    Hi Patrick - I did run both Microsoft Office Diagnostics and the Office repair utility a few days ago but to no avail. Just for fun, I ran them both again this morning and the issue is still there; however, the diagnostic was incomplete because it was missing a file - I'll try it again once it gets downloaded. The script is written to create a new document in a specific Sharepoint site, and I believe that the script is indeed running when I try to open base InfoPath through the Start menu because after the app opens and I see the Getting Started screen for a second before it closes down, I check the Sharepoint site and there is a new document with that exact date and time. It really seems as if the script that I wrote has somehow become embedded in InfoPath so that any time I try to open a form or run any other script it executes. I don't know if that's even possible but I'm sure it's being executed because I can see the results. Oddly, the only time it doesn't generate a new document is when I open an existing InfoPath document in Sharepoint, though I do get the error messagebox I mentioned in my first post. Thanks.

  • 01-25-2008 12:20 PM In reply to

    Re: Persistent InfoPath error

    Hi Srudolph728,

    This is very interesting. I have never heard of anyone writing a default script for all InfoPath forms. I didn't even know it was possible. Usually, the script runs as part of an XSN not as part of InfoPath executable. So what you are saying is: if you just go to Windows->Start and choose InfoPath, it flashes the Getting Started screen and then goes away. You didn't specify a form and yet it creates a new record in SharePoint!? To be honest, I can't imagine how this would happen. Unless you are infected with some rogue application or something, there should be no way of having a script run for all InfoPath forms. That's just impossible.

    Patrick Halstead
    Project Manager at Qdabra
  • 01-25-2008 12:54 PM In reply to

    Re: Persistent InfoPath error

    Hehe - leave it to me to unwittingly create and release a rogue application on my own computer! But what you describe is exactly what's happening. I'll go ahead and post the code here in case it's helpful. I didn't write it myself, it's converted over to .NET from a VB script my department manager found on the web. It's in the codebehind of a Windows form because the idea was to have an .exe that can be called and executed as a scheduled task.

    Public Class Form1

        Private moApp As Microsoft.Office.Interop.InfoPath.Application
        Private moXDoc As Microsoft.Office.Interop.InfoPath.XDocument

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            NewNPQTEST()
            Me.Close()
        End Sub

        Private Sub NewNPQTEST()
            Dim i As Integer, j As Integer

            On Error GoTo MyError
            'Open your custom template in presentation view.
            moApp = New Microsoft.Office.Interop.InfoPath.Application
            moXDoc = moApp.XDocuments.NewFromSolution("http://[server]/IT/requests/NPQTEST/Forms/template.xsn")

            Do While i < moXDoc.DOM.childNodes.length
                Do While j < moXDoc.DOM.childNodes.item(i).childNodes.length
                    Debug.Print(moXDoc.DOM.childNodes.item(i).childNodes.item(j).nodeName)
                    With moXDoc.DOM.childNodes.item(i).childNodes.item(j)
                        Select Case .nodeName
                            Case "my:TestField1"
                                .text = "testing"
                            Case Else
                        End Select
                    End With
                    j = j + 1
                Loop
                i = i + 1
            Loop

            moXDoc.Submit()

            If moApp.XDocuments.Count > 0 Then
                For i = moApp.XDocuments.Count - 1 To 0 Step -1
                    moApp.XDocuments.Close(i)
                Next
            End If

            moApp.Quit()

            moApp = Nothing

            Exit Sub

    MyError:
            MsgBox(Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation, "error in NewNPQTEST")

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