Accessing InfoPath 2007 attachments through an add-in

C

cwhitelm

I am trying to programmatically access the attachments from an open InfoPath
2007 form. I need to save them to disk via a COM add-in. All of the code
examples that I can find use the Microsoft.Office.InfoPath namespace, but
because I am using VSTO 2005, I am in the Microsoft.Office.Interop.InfoPath
namespace. Is there a way to access the actual files and save them to disk? I
have worked through the http://support.microsoft.com/kb/892730 article (which
also uses the 2003 object model), but the node always comes back null even
though there is an attachment on it.

Any ideas?
 
C

cwhitelm

Sure. I have a button on the Main Menu bar of any form that is opened. The
form has been filled out and saved to my c:\ drive. When I click the button,
a method is called with this code in it. I have tried capturing the node
using "/my:myFields/my:Attachment", but the code will not run that way. I
found an example using this method and it runs, but attachmentNode always
returns null when there is an attachment in the control.

Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMNode attachmentNode =

this.Application.ActiveWindow.XDocument.DOM.selectSingleNode("//Title");

Also, (sorry, but I am a newbie at working with InfoPath), how do you debug
an InfoPath add-in in VS2005? I have designed add-ins for PowerPoint and
Outlook and I can debug them by attaching to the process after the
application is open, but with InfoPath, it never attaches to the code. The
only way I have found to follow the code is to put MessageBoxes in place to
spit out values.

Thanks for your help,
Cindy
 
C

cwhitelm

Sorry, the code should read:
Microsoft.Office.Interop.InfoPath.Xml.IXMLDOMNode attachmentNode =
this.Application.ActiveWindow.XDocument.DOM.selectSingleNode("//Attachment");
 
C

cwhitelm

Thanks for the information, but this is not a managed code template. The
add-in runs on any form. I have opened a form and then attached to the
process, but it does not hit the lines of code even though there are
breakpoints. The code runs without problem but never hits the breakpoints
even though it has passed through them.

If you have any other ideas, I would appreciate them.

Thanks!!

Cindy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top