B
bbryenton
I am trying to open another form, actually there are 12 different
forms, from an existing form. The new forms have between 7 - 10
views, and depending on the data entered in the first form, a
different view should appear.
I enter the code
public void OpenNew(string target, string view, bool close)
{
XmlForm f =
this.Application.XmlForms.NewFromFormTemplate(target);
if (close)
this.Close();
try
{
if (f.CurrentView.ViewInfo.Name != view)
{
f.ViewInfos.SwitchView(view);
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "ACS
Infopath Internal");
}
}
The error I get all of the time is:
COM Exception
InfoPath cannot execute any view-related object model calls. The view
is not ready.
System.Runtime.InteropServices.COMException was unhandled by user code
Message="InfoPath cannot execute any view-related object model
calls. The view is not ready."
Source="InfoPath"
ErrorCode=-2147209125
StackTrace:
at
Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String
bstrName)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String
bstrName)
at
Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String
name)
at ACS2.FormCode.OpenNew(String target, String view, Boolean
close)
at ACS2.FormCode.TestView_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)
Any help is appreciated
Thanks, Bob
forms, from an existing form. The new forms have between 7 - 10
views, and depending on the data entered in the first form, a
different view should appear.
I enter the code
public void OpenNew(string target, string view, bool close)
{
XmlForm f =
this.Application.XmlForms.NewFromFormTemplate(target);
if (close)
this.Close();
try
{
if (f.CurrentView.ViewInfo.Name != view)
{
f.ViewInfos.SwitchView(view);
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, "ACS
Infopath Internal");
}
}
The error I get all of the time is:
COM Exception
InfoPath cannot execute any view-related object model calls. The view
is not ready.
System.Runtime.InteropServices.COMException was unhandled by user code
Message="InfoPath cannot execute any view-related object model
calls. The view is not ready."
Source="InfoPath"
ErrorCode=-2147209125
StackTrace:
at
Microsoft.Office.Interop.InfoPath.SemiTrust.View.SwitchView(String
bstrName)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.ViewObjectWrapper.SwitchView(String
bstrName)
at
Microsoft.Office.InfoPath.Internal.ViewInfoCollectionHost.SwitchView(String
name)
at ACS2.FormCode.OpenNew(String target, String view, Boolean
close)
at ACS2.FormCode.TestView_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)
Any help is appreciated
Thanks, Bob