D
daniel1107
Hello,
New to the groups, and I have a question. I could not find a post
similar to this.
What I am trying to do is submit an InfoPath form with Rules and Custom
Code. The Custom Code needs to run first and convert my form to
Microsoft Word 2003. Then my rules are to send the file created (word
document) in an email to select people and also send the document to a
SharePoint document library.
I have the rules working fine. My question is on the custom code. I am
using this code below:
If the submit operation is successful, set
// e.ReturnStatus = true;
// Write your code here.
// Write your code here.
// First create a COM DOM and load the XSL resource file into that
DOM.
IXMLDOMDocument domDocument = thisXDocument.CreateDOM();
domDocument.load("printversion.xsl");
// Create an XmlDocument object and load the XML of the DOM.
XmlDocument xsltDocument = new XmlDocument();
xsltDocument.LoadXml(domDocument.xml);
// Load the InfoPath XML into an XmlDocument object.
XmlDocument infoPathDocument = new XmlDocument();
infoPathDocument.LoadXml(thisXDocument.DOM.xml);
// Load the XSL XmlDocument object into an XslTransform object.
XslTransform xslt = new XslTransform();
xslt.Load(xsltDocument.CreateNavigator(), new XmlUrlResolver(),
this.GetType().Assembly.Evidence);
// Create an output XmlDocument object and load the results of the
transform.
XmlDocument outputDoc = new XmlDocument();
outputDoc.Load(xslt.Transform(infoPathDocument.CreateNavigator(),
null, new XmlUrlResolver()));
// Instantiate Word and insert the output XmlDocument object into a
new document.
object missing = System.Reflection.Missing.Value;
Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.DocumentClass();
oDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing,
ref missing);
wordApp.Selection.Range.InsertXML(outputDoc.OuterXml,ref missing);
wordApp.Visible = true;
which works fine. But when the word document opens, the xml does not
format to the way the InfoPath form looked.
Anybody have some ideas? Im thinking something needs to be done to the
code before it spits the XML to the document but I dont know what.
Also, how would I implement telling InfoPath to send the Word document
in the Rule instead of the InfoPathxsn form?
Thanks, any help would be greatly appreciated.
New to the groups, and I have a question. I could not find a post
similar to this.
What I am trying to do is submit an InfoPath form with Rules and Custom
Code. The Custom Code needs to run first and convert my form to
Microsoft Word 2003. Then my rules are to send the file created (word
document) in an email to select people and also send the document to a
SharePoint document library.
I have the rules working fine. My question is on the custom code. I am
using this code below:
If the submit operation is successful, set
// e.ReturnStatus = true;
// Write your code here.
// Write your code here.
// First create a COM DOM and load the XSL resource file into that
DOM.
IXMLDOMDocument domDocument = thisXDocument.CreateDOM();
domDocument.load("printversion.xsl");
// Create an XmlDocument object and load the XML of the DOM.
XmlDocument xsltDocument = new XmlDocument();
xsltDocument.LoadXml(domDocument.xml);
// Load the InfoPath XML into an XmlDocument object.
XmlDocument infoPathDocument = new XmlDocument();
infoPathDocument.LoadXml(thisXDocument.DOM.xml);
// Load the XSL XmlDocument object into an XslTransform object.
XslTransform xslt = new XslTransform();
xslt.Load(xsltDocument.CreateNavigator(), new XmlUrlResolver(),
this.GetType().Assembly.Evidence);
// Create an output XmlDocument object and load the results of the
transform.
XmlDocument outputDoc = new XmlDocument();
outputDoc.Load(xslt.Transform(infoPathDocument.CreateNavigator(),
null, new XmlUrlResolver()));
// Instantiate Word and insert the output XmlDocument object into a
new document.
object missing = System.Reflection.Missing.Value;
Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.DocumentClass();
oDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing,
ref missing);
wordApp.Selection.Range.InsertXML(outputDoc.OuterXml,ref missing);
wordApp.Visible = true;
which works fine. But when the word document opens, the xml does not
format to the way the InfoPath form looked.
Anybody have some ideas? Im thinking something needs to be done to the
code before it spits the XML to the document but I dont know what.
Also, how would I implement telling InfoPath to send the Word document
in the Rule instead of the InfoPathxsn form?
Thanks, any help would be greatly appreciated.