<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Add C# or Visual Basic to your existing form using VSTO</title><link>http://blogs.msdn.com/b/infopath/archive/2006/06/21/641978.aspx</link><description>Have you ever created an InfoPath form to later discover that you have to write code in order to accomplish something you need? 
   
 If so, you have one of two options: 
   
 You can use VSTA to add managed code to your form.  It is included in the Office</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Add C# or Visual Basic to your existing form using VSTO</title><link>http://blogs.msdn.com/b/infopath/archive/2006/06/21/641978.aspx#1263332</link><pubDate>Tue, 12 Dec 2006 05:04:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1263332</guid><dc:creator>Alnur Ali [MSFT]</dc:creator><description>&lt;p&gt;There is no property explicitly for this.&lt;/p&gt;
&lt;p&gt;You can try a few things&lt;/p&gt;
&lt;p&gt;1) check if the XDocument property != null. You will need to implement some sort of polling/callback mechanism for this yourself.&lt;/p&gt;
&lt;p&gt;2) handle the OnLoad or OnViewSwitch events from your host application (using the IConnectionPointContainer interface for C++ and delegates for .NET).&lt;/p&gt;
&lt;p&gt;.NET snippet:&lt;/p&gt;
&lt;p&gt;namespace IPHosted&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public partial class Form1 : Form&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Form1()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;InitializeComponent();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// sync to the startup event where you can register for individual events&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;formControl1.InternalStartup += new Microsoft.Office.InfoPath.FormControl.EventHandler&amp;lt;EventArgs&amp;gt;(formControl1_InternalStartup);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;void formControl1_InternalStartup(object sender, EventArgs e)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt;			// sync to the View switch event (you can also sync to other form events, such as Save, Merge, etc)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;((FormControl)sender).EventManager.FormEvents.ViewSwitched += new ViewSwitchedEventHandler(OnSwitchView);&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;3) register to receive a callback during the Init event. This event fires before document OnLoad.&lt;/p&gt;
&lt;p&gt;There should be documentation on MSDN for the details of this. Basically you need to implement IInitEventHandler interface and call its SetInitEventHandler passing in pointer to your callback function.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1263332" width="1" height="1"&gt;</description></item><item><title>re: Add C# or Visual Basic to your existing form using VSTO</title><link>http://blogs.msdn.com/b/infopath/archive/2006/06/21/641978.aspx#1224944</link><pubDate>Wed, 06 Dec 2006 23:09:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1224944</guid><dc:creator>bkleynbok</dc:creator><description>&lt;p&gt;How can I know for sure that form is loaded into formControl1?&lt;/p&gt;
&lt;p&gt;There is no event that fires or property being set.&lt;/p&gt;
&lt;p&gt;Is there a way to monitor something on the formControl ?&lt;/p&gt;
&lt;p&gt;-Boris Kleynbok&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1224944" width="1" height="1"&gt;</description></item><item><title>re: Add C# or Visual Basic to your existing form using VSTO</title><link>http://blogs.msdn.com/b/infopath/archive/2006/06/21/641978.aspx#658168</link><pubDate>Thu, 06 Jul 2006 21:48:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:658168</guid><dc:creator>Alnur Ali [MSFT]</dc:creator><description>You actually shouldn't need to use the InfoPath ActiveX component if you want to externally automate the export to PDF action.&lt;br&gt;&lt;br&gt;You can still externally automate InfoPath 2007 just like you could with 2003. &amp;nbsp;Here's a snippet in jscript that should get you about what you want:&lt;br&gt;&lt;br&gt;var appObj = new ActiveXObject(&amp;quot;InfoPath.Application&amp;quot;);&lt;br&gt;appObj.XDocuments.NewFromSolution(&amp;quot;C:\\Documents and Settings\\alnurali\\Desktop\\Template20.xsn&amp;quot;);&lt;br&gt;appObj.XDocuments.Item(0).View.Export(&amp;quot;C:\\Documents and Settings\\alnurali\\Desktop\\Template20CurrentView.PDF&amp;quot;, &amp;quot;PDF&amp;quot;);&lt;br&gt;&lt;br&gt;Note, however, that you may need to add a timer between loading the form and exporting the view. &amp;nbsp;This is because - depending on the complexity of your form - the view may not have fully loaded yet (so any export will of course fail).&lt;br&gt;&lt;br&gt;You can, of course, do the same thing using our ActiveX component, if that's what your needs call for. &amp;nbsp;Again, you just need to call into the InfoPath object model from your host. &amp;nbsp;Here's an example in managed code this time:&lt;br&gt;&lt;br&gt;formControl1.XmlForm.CurrentView.Export(@&amp;quot;C:\Documents and Settings\alnurali\Desktop\Template12CurrentViewPDF.pdf&amp;quot;, Microsoft.Office.InfoPath.ExportFormat.Pdf);&lt;br&gt;&lt;br&gt;The same caution that I mentioned above about waiting for the view to load applies.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=658168" width="1" height="1"&gt;</description></item><item><title>re: Add C# or Visual Basic to your existing form using VSTO</title><link>http://blogs.msdn.com/b/infopath/archive/2006/06/21/641978.aspx#657925</link><pubDate>Thu, 06 Jul 2006 18:16:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:657925</guid><dc:creator>bkleynbok</dc:creator><description>My question is on&lt;br&gt;&lt;br&gt;InfoPath ActiveX component that allows access to the InfoPath object.&lt;br&gt;&lt;br&gt;Is it a part of the VSTO or is it planned to be released separately in the near future.&lt;br&gt;&lt;br&gt;Reason for my inquiry is simple.&lt;br&gt;&lt;br&gt;InfoPath 2007 now offers Export to PDF feature which I would like to take full advantage of and to automate it.&lt;br&gt;&lt;br&gt;How would I go about doing it.&lt;br&gt;&lt;br&gt;Best Regards,&lt;br&gt;&lt;br&gt;Boris&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=657925" width="1" height="1"&gt;</description></item></channel></rss>