473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

C# dotnet and Word Automation

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?
Jul 21 '05 #1
2 3607
It should be one of the WdSaveFormat enumerated values (probably
WdFormatXML = 11).

See the Document.SaveAs documentation on MSDN:
http://msdn.microsoft.com/library/de...asp?frame=true

I got the value of the constant from this page:
http://msdn.microsoft.com/library/de...asp?frame=true
Joshua Flanagan
http://flimflan.com/blog
ANDY wrote:
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?

Jul 21 '05 #2
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.

"Joshua Flanagan" wrote:
It should be one of the WdSaveFormat enumerated values (probably
WdFormatXML = 11).

See the Document.SaveAs documentation on MSDN:
http://msdn.microsoft.com/library/de...asp?frame=true

I got the value of the constant from this page:
http://msdn.microsoft.com/library/de...asp?frame=true
Joshua Flanagan
http://flimflan.com/blog
ANDY wrote:
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?

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mickeydisn | last post by:
Sub: C++ Word automation Extract text hello. I want extact text form a word document using a visual c++ programme. I have see a lot of documentation. and my analysis is that I must use a...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
6
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would...
2
by: kids | last post by:
Does anybody know any reason which could cause Ms. word automation to crash? I try to call word automation to open a document and use find and replace function. For some reason it works but I...
4
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my c#-project, i want to use the system.reflection model to...
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
2
by: Radek | last post by:
Hi, I have got such problem: in my directory "C:\folder" I have 3 files in MS WORD (having tables, images etc), these are: "1.doc", "2.doc", "3.doc". I want to write an application (C# of...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
5
by: Daniel Walzenbach | last post by:
Hi, I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed). The preferable solution would be...
1
by: bluestar | last post by:
hello i am trying to develope an application for word automation.i need to insert header and footer to the document. i found an exampke in msdn and used it in my application.it works well;but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.