Hi there,
I'm attempting to create a simple C# button that can convert a # of InfoPath forms to PDF (60+). My knowledge of C# is basic but I would really like to take a stab at this as it would diminish quite a bit of administration time (and the use of any third-party off-the-shelf solutions). I am creating this within an InfoPath form external to any of the forms being converted (I would rather create a stand-alone program using C# but my references within Visual C# Exp refuse to play nicely)!
I receive the following error (I was able to find a few solutions to it but none seem to cooperate with my code very well):
"InfoPath cannot execute any view-related object model calls. The view is not ready."
Here is the code I currently have:
public void Converion_Clicked(object sender, ClickedEventArgs e)
{
string[] fileEntries = Directory.GetFiles("C:\\Test");foreach (string fileName in fileEntries)
{
Application.XmlForms.Open(fileName,
XmlFormOpenMode.ReadOnly);Application.ActiveWindow.XmlForm.CurrentView.Export(@fileName + ".pdf", ExportFormat.Pdf);
Application.ActiveWindow.Close(
true);
}
The error takes place when it attempts to export; I'm attempting to open each form, export to PDF, close, and repeat. Every form within that folder has "View 1" as its view name, and so does the main form with the button. I attempted to use the SwitchView control/function but that failed (didn't know where to how use it)!
Your help would be most appreciated - thank you!