<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/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>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Adding another attachment field</title><link>https://www.infopathdev.com:443/forums/thread/51656.aspx</link><pubDate>Wed, 10 Feb 2010 23:09:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51656</guid><dc:creator>Lawson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51656.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=51656</wfw:commentRss><description>&lt;p&gt;Ha, thanks, he&amp;#39;s my sidekick :)&lt;/p&gt;</description></item><item><title>Re: Adding another attachment field</title><link>https://www.infopathdev.com:443/forums/thread/51655.aspx</link><pubDate>Wed, 10 Feb 2010 22:22:19 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51655</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51655.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=51655</wfw:commentRss><description>&lt;p&gt;You are very welcome, and your dog (I&amp;#39;m assuming the dog in your profile pic is yours?) is ADORABLE! &lt;/p&gt;</description></item><item><title>Re: Adding another attachment field</title><link>https://www.infopathdev.com:443/forums/thread/51654.aspx</link><pubDate>Wed, 10 Feb 2010 20:43:06 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51654</guid><dc:creator>Lawson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51654.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=51654</wfw:commentRss><description>&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:10pt;"&gt;Hilary,&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:10pt;"&gt;Once again, you&amp;#39;re AWESOME!&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:10pt;"&gt;I made the necessary changes, and the problem has been solved.&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:10pt;"&gt;Thanks for all of your help.&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;FONT-SIZE:10pt;"&gt;-Lawson&lt;/span&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Adding another attachment field</title><link>https://www.infopathdev.com:443/forums/thread/51650.aspx</link><pubDate>Wed, 10 Feb 2010 20:18:35 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51650</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51650.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=51650</wfw:commentRss><description>&lt;p&gt;Are you sure of your XPath:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#800000" face="Courier New"&gt;my:myFields/my:theAttachment2Field&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Did you use the &lt;strong&gt;Copy XPath&lt;/strong&gt; menu option in the Data Source Task Pane to get that XPath to your field? In the Data Source Task Pane, make sure your Main data source is displayed, and right click on the field and select &lt;strong&gt;Copy XPath&lt;/strong&gt;. Then paste that XPath into your code:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font face="Courier New"&gt;&lt;font color="#008080"&gt;IXMLDOMNode&lt;/font&gt;&lt;font size="2"&gt; nn = thisXDocument.DOM.selectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;my:myFields/my:theAttachment2Field&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Replacing the original XPath with the one you just copied from the data source.&lt;/p&gt;</description></item><item><title>Adding another attachment field</title><link>https://www.infopathdev.com:443/forums/thread/51649.aspx</link><pubDate>Wed, 10 Feb 2010 19:51:41 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:51649</guid><dc:creator>Lawson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/51649.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=51649</wfw:commentRss><description>&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;I have an InfoPath 2007 form that uses the Microsoft example Encoder and Decoder found at the following website. &lt;/font&gt;&lt;a href="http://support.microsoft.com/kb/892730"&gt;&lt;font size="3" face="Calibri"&gt;http://support.microsoft.com/kb/892730&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;I would like to add one more attachment field to the save button, so when the save button is clicked, the contents of both attachment fields are saved to the specified folder. &lt;/font&gt;&lt;/p&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt; 
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;font size="3" face="Calibri"&gt;The save button has the following code. &lt;/font&gt;&lt;/p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font size="2"&gt;[&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathEventHandler&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(MatchPath = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;btnSave&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, EventType = &lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathEventType&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.OnClick)]&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; btnSave_OnClick(&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;DocActionEvent&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; e)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//Get a reference to the attachment node.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;IXMLDOMNode&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; n = thisXDocument.DOM.selectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;my:myFields/my:theAttachmentField&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//Get the text of the node.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;String&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; theAttachment = n.text;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (theAttachment.Length &amp;gt; 0)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;InfoPathAttachmentEncoding.&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathAttachmentDecoder&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; myDecoder = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; InfoPathAttachmentEncoding.&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathAttachmentDecoder&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(theAttachment);&lt;/p&gt;myDecoder.SaveAttachment(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;@&amp;quot;C:\Users\Lawson\Documents\InfoPath Forms&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;--------------------------------------------------------------------------------------------------------------------------&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I added the following code in an effort to save the second attachment like the first.&lt;/strong&gt;&lt;/p&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt; 
&lt;p&gt;//Get a reference to the attachment node.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;IXMLDOMNode&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; nn = thisXDocument.DOM.selectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;my:myFields/my:theAttachment2Field&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//Get the text of the node.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;String&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; theAttachment2 = nn.text;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (theAttachment2.Length &amp;gt; 0)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;InfoPathAttachmentEncoding.&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathAttachmentDecoder&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; myDecoder = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; InfoPathAttachmentEncoding.&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;font color="#008080" size="2"&gt;InfoPathAttachmentDecoder&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(theAttachment2);&lt;/p&gt;myDecoder.SaveAttachment(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;@&amp;quot;C:\Users\Lawson\Documents\InfoPath Forms&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;} &lt;/p&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="LINE-HEIGHT:115%;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;FONT-SIZE:10pt;mso-no-proof:yes;"&gt;However, I get the following message after I debug the form and try to test it. &lt;/span&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt; &lt;/font&gt;&lt;/span&gt;
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;font face="Calibri"&gt;&lt;font size="3"&gt;NullReferenceException was unhandled by user code.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0in 0in 10pt;" class="MsoNormal"&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;font size="3" face="Calibri"&gt;Object reference not set to an instance of an object.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;font face="Calibri"&gt;&lt;font size="3"&gt;TroubleShooting tips:Use the “new” keyword to create an object instance.&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;/span&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;/span&gt;&lt;span style="mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri;"&gt;&lt;/span&gt;&lt;font size="3"&gt;&lt;span&gt;For this line&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;font size="3"&gt;&lt;span&gt;&lt;/span&gt;&lt;/font&gt;&lt;font face="Times New Roman"&gt;&lt;span style="COLOR:teal;FONT-SIZE:10pt;"&gt;String&lt;/span&gt;&lt;span style="COLOR:black;FONT-SIZE:10pt;"&gt; theAttachment2 = nn.text;&lt;/span&gt;&lt;span style="COLOR:teal;FONT-SIZE:10pt;"&gt;&lt;/span&gt;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;&amp;nbsp;&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;Does anybody have any suggestions on how to either fix this error, or go about this a different way?&lt;/font&gt;&amp;nbsp;&lt;font size="3" face="Calibri"&gt;Thanks,&lt;/font&gt;&lt;font size="3" face="Calibri"&gt;-Lawson&lt;/font&gt;&amp;nbsp; 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>