C# dotnet and Word Automation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to save a document (automatically) to an XML document.

I am using the following code:

wrdApp.ActiveDocument.SaveAs(ref oOutFileName, ref oFormat, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing,ref oMissing,ref
oMissing,ref oMissing,ref oMissing,ref oMissing);

The intellisense tells me that the 2nd parameter (where I have oFormat) is
for the format of the document. However, I have not been able to find what
the format of this should be. I have tried

object oFormat = "XML";
object oFormat = "2";
object oFormat = "XML Document";

etc.

Does anyone know the correct syntax for my oFormat variable?
 
Is there anywhere with an example? This says to use the wdSaveFormat constant

Can be any WdSaveFormat constant. The one I want is wdFormatXML. If I put
the line in Object oFormat = "wdFormatXML", the program errors out at that
point - Type Mismatch. If I take off the quotes, like in the VB examples
given, I get wdFormatXML is not defined. I figure it is some component of
the Office.Core library, but can't seem to find it.
 
Back
Top