Hi Cathy,
I tried below the code in InfoPath 2007.
Its worked for me and InfoPath form is closing when I click on button.
XDocument.View.Window.Close(true);
Can you add try and catch block to above statement and let you know what type of error it is giving?
try
{
XDocument.View.Window.Close(true);
XDocument.UI.Alert("The form has been successfully closed");
}
catch(Exception ex)
{
XDocument.UI.Alert(ex.Message);
}
Hope this helps you