<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Nishant Rana's Weblog</title>
	<atom:link href="http://nishantrana.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nishantrana.wordpress.com</link>
	<description>Everything related to Microsoft .NET technology</description>
	<pubDate>Fri, 18 Jul 2008 10:36:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
			<item>
		<title>Setting Built In and Custom Document Properties using C#</title>
		<link>http://nishantrana.wordpress.com/2008/07/18/setting-built-in-and-custom-document-properties-using-c/</link>
		<comments>http://nishantrana.wordpress.com/2008/07/18/setting-built-in-and-custom-document-properties-using-c/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 10:36:36 +0000</pubDate>
		<dc:creator>Nishant Rana</dc:creator>
		
		<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<category><![CDATA[Word InterOp]]></category>

		<guid isPermaLink="false">http://nishantrana.wordpress.com/?p=137</guid>
		<description><![CDATA[Create a new windows application project and add a button to it.
On click of that button, we will open a document and add values for a built in and custom document properties.
Than add reference to (Word 10.0 or 11.0 object library) and Microsoft.Office.Core.dll within COM tab of Add reference dialog box.
After adding reference, add this [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="font-size:11pt;">Create a new windows application project and add a button to it.</span></p>
<p><span style="font-size:11pt;">On click of that button, we will open a document and add values for a built in and custom document properties.</span></p>
<p><span style="font-size:11pt;">Than add reference to (Word 10.0 or 11.0 object library) and Microsoft.Office.Core.dll within COM tab of Add reference dialog box.</span></p>
<p><span style="font-size:11pt;">After adding reference, add this directive</span></p>
<p><em><strong><span style="font-size:11pt;">using Microsoft.Office.Interop.Word</span></strong></em></p>
<p><em><strong>using System.Reflection;</strong></em></p>
<p>Put the following code in the button click event handler</p>
<p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin-top:0in; 	mso-para-margin-right:0in; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// For optional parameters create a missing object</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> missing = System.Reflection.<span style="color:teal;">Missing</span>.Value;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// Create an object for filename which is the file to be opened<span> </span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> fileName = <span style="color:maroon;">@&#8221;C:\MySecond.doc&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// Create an object of application class</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">ApplicationClass</span> WordApp = <span style="color:blue;">new</span> <span style="color:teal;">ApplicationClass</span>();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// open the document specified in the fileName variable</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Document</span> adoc = WordApp.Documents.Open(<span style="color:blue;">ref</span> fileName, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// setting the document built in properties</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> oDocBuiltInProps = adoc.BuiltInDocumentProperties;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Type</span> typeDocBuiltInProps = oDocBuiltInProps.GetType();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// setting the Title property with value &#8220;My Proposal&#8221;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span> </span><span style="color:blue;">string</span> strIndex = <span style="color:maroon;">&#8220;Title&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> strValue = <span style="color:maroon;">&#8220;My Proposal&#8221;</span>;<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>typeDocBuiltInProps.InvokeMember(<span style="color:maroon;">&#8220;Item&#8221;</span>,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">BindingFlags</span>.Default |</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">BindingFlags</span>.SetProperty,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">null</span>, oDocBuiltInProps,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">new</span> <span style="color:blue;">object</span>[] { strIndex, strValue });</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// setting the custome document properties</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> oDocCustomProps = adoc.CustomDocumentProperties;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Type</span> typeDocCustomProps = oDocCustomProps.GetType();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// setting the ProposalSentDate custom date property with current date time </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> strIndex1 = <span style="color:maroon;">&#8220;ProposalSentDate&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">string</span> strValue1 = <span style="color:teal;">DateTime</span>.Now.ToShortDateString();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span>[] oArg = { strIndex1, <span style="color:blue;">false</span>, Microsoft.Office.Core.<span style="color:teal;">MsoDocProperties</span>.msoPropertyTypeDate, strValue1 };</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>typeDocCustomProps.InvokeMember(<span style="color:maroon;">&#8220;Add&#8221;</span>,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">BindingFlags</span>.Default |</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">BindingFlags</span>.InvokeMethod, <span style="color:blue;">null</span>,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>oDocCustomProps,oArg);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;"><span> </span>WordApp.Visible = <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal">
<p class="MsoNormal">Byee&#8230;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nishantrana.wordpress.com/137/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nishantrana.wordpress.com/137/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nishantrana.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nishantrana.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nishantrana.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nishantrana.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nishantrana.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nishantrana.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nishantrana.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nishantrana.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nishantrana.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nishantrana.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nishantrana.wordpress.com&blog=1794554&post=137&subd=nishantrana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nishantrana.wordpress.com/2008/07/18/setting-built-in-and-custom-document-properties-using-c/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/nishantrana-128.jpg" medium="image">
			<media:title type="html">nishu</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating and Updating table of contents in word document using C#</title>
		<link>http://nishantrana.wordpress.com/2008/07/17/creating-and-updating-table-of-contents-in-word-document-using-c/</link>
		<comments>http://nishantrana.wordpress.com/2008/07/17/creating-and-updating-table-of-contents-in-word-document-using-c/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 16:18:34 +0000</pubDate>
		<dc:creator>Nishant Rana</dc:creator>
		
		<category><![CDATA[Word InterOp]]></category>

		<guid isPermaLink="false">http://nishantrana.wordpress.com/?p=128</guid>
		<description><![CDATA[

Create a new windows application project and add a button to it.
On click of that button, we will open a document and first add a heading 1 programmatically and then
inserting a table of content programmatically and updating it
Than add reference to (Word 10.0 or 11.0 object library) within COM tab of Add reference dialog box.
After [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman";} p 	{mso-style-noshow:yes; 	mso-style-priority:99; 	mso-margin-top-alt:auto; 	margin-right:0in; 	mso-margin-bottom-alt:auto; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman","serif"; 	mso-fareast-font-family:"Times New Roman";} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-size:10.0pt; 	mso-ansi-font-size:10.0pt; 	mso-bidi-font-size:10.0pt; 	mso-ascii-font-family:Calibri; 	mso-hansi-font-family:Calibri;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --></p>
<p><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} --></p>
<p><!--[endif]--><span style="font-size:11pt;">Create a new windows application project and add a button to it.</span></p>
<p><span style="font-size:11pt;">On click of that button, we will open a document and first add a heading 1 programmatically and then</span></p>
<p>inserting a table of content programmatically and updating it</p>
<p><span style="font-size:11pt;">Than add reference to (Word 10.0 or 11.0 object library) within COM tab of Add reference dialog box.</span></p>
<p><span style="font-size:11pt;">After adding reference, add this directive</span></p>
<p><strong><span style="font-size:11pt;">using Microsoft.Office.Interop.Word</span></strong></p>
<p>Put the following code in the button click event handler</p>
<p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Cambria; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073741899 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-fareast-font-family:"Times New Roman"; 	mso-bidi-font-family:"Times New Roman";} h1 	{mso-style-priority:9; 	mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-link:"Heading 1 Char"; 	mso-style-next:Normal; 	margin-top:12.0pt; 	margin-right:0in; 	margin-bottom:3.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	page-break-after:avoid; 	mso-outline-level:1; 	font-size:16.0pt; 	font-family:"Cambria","serif"; 	mso-font-kerning:16.0pt;} span.Heading1Char 	{mso-style-name:"Heading 1 Char"; 	mso-style-priority:9; 	mso-style-unhide:no; 	mso-style-locked:yes; 	mso-style-link:"Heading 1"; 	mso-ansi-font-size:16.0pt; 	mso-bidi-font-size:16.0pt; 	font-family:"Cambria","serif"; 	mso-ascii-font-family:Cambria; 	mso-hansi-font-family:Cambria; 	mso-font-kerning:16.0pt; 	font-weight:bold;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	font-size:10.0pt; 	mso-ansi-font-size:10.0pt; 	mso-bidi-font-size:10.0pt; 	mso-ascii-font-family:Calibri; 	mso-hansi-font-family:Calibri;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin:0in; 	mso-para-margin-bottom:.0001pt; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// For optional parameters create a missing object</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> missing = System.Reflection.<span style="color:teal;">Missing</span>.Value;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// Create an object for filename which is the file to be opened<span> </span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> fileName = <span style="color:maroon;">@&#8221;C:\MySecond.doc&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// Create an object of application class</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">ApplicationClass</span> WordApp = <span style="color:blue;">new</span> <span style="color:teal;">ApplicationClass</span>();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// open the document specified in the fileName variable</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Document</span> adoc = WordApp.Documents.Open(<span style="color:blue;">ref</span> fileName, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Range</span> myRange = adoc.Range(<span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>myRange.InsertAfter(<span style="color:maroon;">&#8220;Hello Mickey Mouse GG &#8220;</span>);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> oStyleName = <span style="color:maroon;">&#8220;Heading 1&#8243;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>myRange.set_Style(<span style="color:blue;">ref</span> oStyleName);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> start=WordApp.ActiveDocument.Content.End - 1;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Range</span> rangeForTOC = adoc.Range(<span style="color:blue;">ref</span> start, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">TableOfContents</span> toc=adoc.TablesOfContents.Add(rangeForTOC, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,<span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>toc.Update();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Range</span> rngTOC = toc.Range;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>rngTOC.Font.Size = 10;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;line-height:115%;font-family:&quot;"><span> </span>rngTOC.Font.Name = <span style="color:maroon;">&#8220;Georgia&#8221;</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>WordApp.Visible = <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">Bye&#8230;</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nishantrana.wordpress.com/128/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nishantrana.wordpress.com/128/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nishantrana.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nishantrana.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nishantrana.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nishantrana.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nishantrana.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nishantrana.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nishantrana.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nishantrana.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nishantrana.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nishantrana.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nishantrana.wordpress.com&blog=1794554&post=128&subd=nishantrana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nishantrana.wordpress.com/2008/07/17/creating-and-updating-table-of-contents-in-word-document-using-c/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/nishantrana-128.jpg" medium="image">
			<media:title type="html">nishu</media:title>
		</media:content>
	</item>
		<item>
		<title>Opening and inserting a picture in word document programmatically using C#</title>
		<link>http://nishantrana.wordpress.com/2008/07/17/opening-and-inserting-a-picture-in-word-document-programmatically-using-c/</link>
		<comments>http://nishantrana.wordpress.com/2008/07/17/opening-and-inserting-a-picture-in-word-document-programmatically-using-c/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 13:40:40 +0000</pubDate>
		<dc:creator>Nishant Rana</dc:creator>
		
		<category><![CDATA[Word InterOp]]></category>

		<guid isPermaLink="false">http://nishantrana.wordpress.com/?p=125</guid>
		<description><![CDATA[ 
Create a new windows application project and add a button to it.
On click of that button, we will open a document and insert a picture to it.
(In the doc file insert a table at the location where you want the picture to appear.)
Than add reference to (Word 10.0 or 11.0 object library) within COM [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face 	{font-family:Georgia; 	panose-1:2 4 5 2 5 4 5 2 3 3; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:647 0 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} p 	{mso-style-noshow:yes; 	mso-style-priority:99; 	mso-margin-top-alt:auto; 	margin-right:0in; 	mso-margin-bottom-alt:auto; 	margin-left:0in; 	mso-pagination:widow-orphan; 	font-size:12.0pt; 	font-family:"Times New Roman","serif"; 	mso-fareast-font-family:"Times New Roman";} span.mceitemhidden 	{mso-style-name:mceitemhidden; 	mso-style-unhide:no;} span.mceitemhiddenspellword 	{mso-style-name:mceitemhiddenspellword; 	mso-style-unhide:no;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin-top:0in; 	mso-para-margin-right:0in; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --> <!--[endif]--></p>
<p><span style="font-size:11pt;font-family:&quot;">Create a new windows application project and add a button to it.</span></p>
<p><span style="font-size:11pt;font-family:&quot;">On click of that button, we will open a document and insert a picture to it.</span></p>
<p><span style="font-size:11pt;font-family:&quot;">(</span><span style="font-size:11pt;font-family:&quot;">In the doc file insert a table at the location where you want the picture to appear.)</span></p>
<p><span style="font-size:11pt;font-family:&quot;">Than add reference to (Word 10.0 or 11.0 object library) within COM tab of Add reference dialog box.</span></p>
<p><span style="font-size:11pt;font-family:&quot;">After adding reference, add this directive</span></p>
<p><span class="mceitemhidden"><strong><span style="font-size:11pt;font-family:&quot;">using Microsoft.Office.</span></strong></span><span class="mceitemhiddenspellword"><strong><span style="font-size:11pt;font-family:&quot;">Interop</span></strong></span><span class="mceitemhidden"><strong><span style="font-size:11pt;font-family:&quot;">.Word</span></strong></span></p>
<p>Put the following code in the button click event handler</p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// For optional parameters create a missing object</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:blue;">object</span> missing = System.Reflection.<span style="color:teal;">Missing</span>.Value;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// Create an object for filename, which is the file to be opened </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:blue;">object</span> fileName=<span style="color:maroon;">@&#8221;C:\MySecond.doc&#8221;</span>; </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// Create an object of application class</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:teal;">ApplicationClass</span> WordApp = <span style="color:blue;">new</span> <span style="color:teal;">ApplicationClass</span>();</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// open the document specified in the fileName variable</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:teal;">Document</span> adoc = WordApp.Documents.Open(<span style="color:blue;">ref</span> fileName, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing,</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// We can insert the picture using Range objects AddPicture method</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// To insert a picture at a particular location in the word document</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// insert a table over there and then refer that location through range object</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:teal;">Range</span> rngPic = adoc.Tables[1].Range; </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">// we can even select a particular cell in the table </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> <span style="color:green;">//Range rngPic = rng.Tables[1].Cell(2, 3).Range;</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> rngPic.InlineShapes.AddPicture(<span style="color:maroon;">@&#8221;C:\anne_hathaway.jpg&#8221;</span>, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-family:&quot;"> WordApp.Visible = <span style="color:blue;">true</span>;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;">
<p><span class="mceitemhidden"><strong><span style="font-size:11pt;font-family:&quot;"> </span></strong></span></p>
<p><span style="font-size:11pt;font-family:&quot;">Bye<br />
</span></p>
<p class="MsoNormal"><span style="font-family:&quot;"> </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nishantrana.wordpress.com/125/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nishantrana.wordpress.com/125/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nishantrana.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nishantrana.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nishantrana.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nishantrana.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nishantrana.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nishantrana.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nishantrana.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nishantrana.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nishantrana.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nishantrana.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nishantrana.wordpress.com&blog=1794554&post=125&subd=nishantrana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nishantrana.wordpress.com/2008/07/17/opening-and-inserting-a-picture-in-word-document-programmatically-using-c/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/nishantrana-128.jpg" medium="image">
			<media:title type="html">nishu</media:title>
		</media:content>
	</item>
		<item>
		<title>Inserting or appending document or file in a word document programmatically using C#</title>
		<link>http://nishantrana.wordpress.com/2008/07/17/inserting-or-appending-document-or-file-in-a-word-document-programmatically-using-c/</link>
		<comments>http://nishantrana.wordpress.com/2008/07/17/inserting-or-appending-document-or-file-in-a-word-document-programmatically-using-c/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 12:29:25 +0000</pubDate>
		<dc:creator>Nishant Rana</dc:creator>
		
		<category><![CDATA[Word InterOp]]></category>

		<guid isPermaLink="false">http://nishantrana.wordpress.com/?p=122</guid>
		<description><![CDATA[Create a new windows application project and add a button to it.
On click of that button, we will create a new document and append or insert content of two documents in it.
First add reference to (Word 10.0 or 11.0 object library) within COM tab of Add reference dialog box.
After adding reference, add this directive
using Microsoft.Office.Interop.Word
Put [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Create a new windows application project and add a button to it.</p>
<p>On click of that button, we will create a new document and append or insert content of two documents in it.</p>
<p>First add reference to (Word 10.0 or 11.0 object library) within COM tab of Add reference dialog box.</p>
<p>After adding reference, add this directive</p>
<p><strong>using Microsoft.Office.Interop.Word</strong></p>
<p>Put this code on button click</p>
<p><!--[if gte mso 9]&gt;  Normal 0     false false false  EN-US X-NONE X-NONE              MicrosoftInternetExplorer4              &lt;![endif]--><!--[if gte mso 9]&gt;                                                                                                                                            &lt;![endif]--><!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:1; 	mso-generic-font-family:roman; 	mso-font-format:other; 	mso-font-pitch:variable; 	mso-font-signature:0 0 0 0 0 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0in; 	margin-right:0in; 	margin-bottom:10.0pt; 	margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:8.5in 11.0in; 	margin:1.0in 1.0in 1.0in 1.0in; 	mso-header-margin:.5in; 	mso-footer-margin:.5in; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --><!--[if gte mso 10]&gt; &lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0in 5.4pt 0in 5.4pt; 	mso-para-margin-top:0in; 	mso-para-margin-right:0in; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0in; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --> <!--[endif]--></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> // For optional parameters create a missing object</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> missing = System.Reflection.<span style="color:teal;">Missing</span>.Value;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// Create an object of application class</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">ApplicationClass</span> WordApp = <span style="color:blue;">new</span> <span style="color:teal;">ApplicationClass</span>();<span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// add a document in the Application </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Document</span> adoc=WordApp.Documents.Add(<span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// declare variables for setting the position within the document</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> start = 0;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:blue;">object</span> end = 0;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// create a range object which starts at 0</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Range</span> rng = adoc.Range(<span style="color:blue;">ref</span> start, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// insert a file </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>rng.InsertFile(<span style="color:maroon;">@&#8221;C:\MyFirst.doc&#8221;</span>, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// now make start to point to the end of the content of the first document</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>start = WordApp.ActiveDocument.Content.End - 1;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// create another range object with the new value for start</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:teal;">Range</span> rng1 = adoc.Range(<span style="color:blue;">ref</span> start, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// insert the another document</span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>rng1.InsertFile(<span style="color:maroon;">@&#8221;C:\MySecond.doc&#8221;</span>, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing, <span style="color:blue;">ref</span> missing);</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// now make start to point to the end of the content of the first document<span> </span></span></span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span>start = WordApp.ActiveDocument.Content.End - 1;</span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"> </span></p>
<p class="MsoNormal" style="margin-bottom:0.0001pt;line-height:normal;"><span style="font-size:10pt;font-family:&quot;"><span> </span><span style="color:green;">// make the word appliction visible</span></span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:&quot;"><span> </span>WordApp.Visible = <span style="color:blue;">true</span>;</span></p>
<p><strong><span style="color:#0000ff;"><strong>Bye<br />
</strong></span></strong></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nishantrana.wordpress.com/122/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nishantrana.wordpress.com/122/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nishantrana.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nishantrana.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nishantrana.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nishantrana.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nishantrana.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nishantrana.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nishantrana.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nishantrana.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nishantrana.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nishantrana.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nishantrana.wordpress.com&blog=1794554&post=122&subd=nishantrana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nishantrana.wordpress.com/2008/07/17/inserting-or-appending-document-or-file-in-a-word-document-programmatically-using-c/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/nishantrana-128.jpg" medium="image">
			<media:title type="html">nishu</media:title>
		</media:content>
	</item>
		<item>
		<title>Upgrade or Using CRM 3 callouts in CRM 4</title>
		<link>http://nishantrana.wordpress.com/2008/07/15/upgrade-or-using-crm-3-callouts-in-crm-4/</link>
		<comments>http://nishantrana.wordpress.com/2008/07/15/upgrade-or-using-crm-3-callouts-in-crm-4/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 13:02:25 +0000</pubDate>
		<dc:creator>Nishant Rana</dc:creator>
		
		<category><![CDATA[Microsoft Dynamics CRM]]></category>

		<category><![CDATA[CRM]]></category>

		<guid isPermaLink="false">http://nishantrana.wordpress.com/?p=116</guid>
		<description><![CDATA[Hi,
These are the steps we followed for using crm 3.0 callouts in crm 4.0
In one case we upgraded our crm 3.0 to crm 4.0,
We had to put our crm 3.0 callouts in the following path
C:\Program Files\Microsoft CRM\Server\bin\assembly
We also had to put Microsoft.Crm.Platform.Callout.Base in the GAC.
Followed by an IISRESET
In second case, we had a fresh installation [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Hi,</p>
<p>These are the steps we followed for using crm 3.0 callouts in crm 4.0</p>
<p>In one case we upgraded our crm 3.0 to crm 4.0,</p>
<p>We had to put our crm 3.0 callouts in the following path</p>
<p><span style="color:#800000;"><strong>C:\Program Files\<em><span style="color:#0000ff;">Microsoft CRM</span></em>\Server\bin\assembly</strong></span></p>
<p>We also had to put <strong>Microsoft.Crm.Platform.Callout.Base</strong> in the GAC.</p>
<p>Followed by an IISRESET</p>
<p>In second case, we had a fresh installation of  CRM 4.0.</p>
<p>We had to put our crm 3.0 callouts in the following path</p>
<p><span style="color:#800000;"><strong>C:\Program Files\<em><span style="color:#0000ff;">Microsoft Dynamics CRM</span></em>\Server\bin\assembly</strong></span>.</p>
<p>Followed by an IISRESET.</p>
<p>And things worked fine for us!!!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/nishantrana.wordpress.com/116/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/nishantrana.wordpress.com/116/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/nishantrana.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/nishantrana.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/nishantrana.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/nishantrana.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/nishantrana.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/nishantrana.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/nishantrana.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/nishantrana.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/nishantrana.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/nishantrana.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=nishantrana.wordpress.com&blog=1794554&post=116&subd=nishantrana&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://nishantrana.wordpress.com/2008/07/15/upgrade-or-using-crm-3-callouts-in-crm-4/feed/</wfw:commentRss>
	
		<media:content url="http://a.wordpress.com/avatar/nishantrana-128.jpg" medium="image">
			<media:title type="html">nishu</media:title>
		</media:content>
	</item>
	</channel>
</rss>