Print Code has stopped working - Value does not fall within the expected range. - InfoPath Dev
in

InfoPath Dev

Print Code has stopped working - Value does not fall within the expected range.

Last post 01-22-2014 02:57 AM by Dragonranger. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 02-10-2010 10:38 AM

    Print Code has stopped working - Value does not fall within the expected range.

    Hi all,

    I have a 2007 form which has been working.  It is quite a complex form with lots of fields and conditional formatting.  Almost all of the features have been achieved using rules.   There is one button on the form which calls code. The code is in VB. This is the only routine in the form.

    Public Sub PRINTFORM_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    Print(True)

    End Sub

    The code compiles with no errors. This button has been working correctly.  But now it does not work, I get exception errors.

    System.ArgumentException
    Value does not fall within the expected range.
       at Microsoft.Office.Interop.InfoPath.SemiTrust.ICLRExtensions.PrintWithDialog()
       at Microsoft.Office.Interop.InfoPath.SemiTrust.ICLRExtensionsWrapper.PrintWithDialog()
       at Microsoft.Office.InfoPath.Internal.XmlFormHost.Print(Boolean showPrintDialog)
       at Microsoft.Office.InfoPath.XmlFormHostItem.Print(Boolean showPrintDialog)
       at JSAWPv01._02.FormCode.PRINTFORM_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    I have deleted the code and re written the line and I get the same error.  I have created a brand new empty form and put one button on with the same code and it works fine.  (I have other forms where this same print button works ok).

    What is this error trying to tell me ?  Where should I be looking ?  Any help would be VERY welcome.

    Thank you

    Catharine

     

  • 02-12-2010 08:27 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

    If this code works in other forms, then it is probably an issue with the view. Try this:

    First thing to try:

    1. Since this is the only code in the form, go into Tools | Form Options | Programming and click the Remove Code button.
    2. Now add your Clicked event from the print button again.
    3. Add the code back in and preview.

    Second thing to try:

    1. Make a copy of your solution (so as not to destroy your original).
    2. Remove some items from the view, preview, and try printing.
    3. Keep doing #2 above until you find the problem spot--and then try to identify what in that spot might be causing the trouble
    4. If you remove all items from the view and continue to get the issue, try the same thing on each other view.
    5. If all views are now blank and you still get the issue, then there's something wrong with the form template internals.
  • 02-12-2010 08:40 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

     

    Thank you for the reply.  I have already tried the First thing to try, and I still get a failure.  I will try #2.  Is there anything that is particularly vulnerable to this error ?

    Catharine

  • 02-12-2010 10:34 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

    Not that I am aware of. But sometimes when a form gets to be complex, as you described yours to be, strange things can start to occur. It takes some investigation and understanding of how InfoPath works in the background. The first thing is to narrow it down--identify the exact source of the problem. Then, if after playing with it a while, you can't figure out how to fix it yourself, it's time to pull in the big guns. If they can't fix it, it could be a legitimate bug that Microsoft would need to address.

  • 02-12-2010 11:38 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

    Hi I have now taken everything off the view - other than the button.  There is only one view in the form.  I still get the error.

    I don't know where to go from here.  Where are the big guns ? 

    Catharine

  • 02-15-2010 11:38 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

    Attach your stripped-down form here and we can look at it.

  • 01-22-2014 02:57 AM In reply to

    Re: Print Code has stopped working - Value does not fall within the expected range.

    Just in case anyone is reading this and still can't find a solution....

    I had the exact same error and it was caused by the footer using a specific locale in date formatting instead of the localised date.  

    Now  I'm not suggesting this is your issue but the way I diagnosed this issue was by trying the Print command from the menu and noting that it threw an exception here as well.

    What I am saying is that this very strange error is more than likely caused by an error in the view as Greg suggested. But it is not necessarily limited to the contents but also, headers/footers or other view/print settings.

    Hope that this can help someone in future. 

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