473,605 Members | 2,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# dotnet and Word Automation

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

I am using the following code:

wrdApp.ActiveDo cument.SaveAs(r ef 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 3616
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.ActiveDo cument.SaveAs(r ef 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 = "wdFormatXM L", 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.ActiveDo cument.SaveAs(r ef 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
12071
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 "word automation". I have foud a lot of exemple to use it but I need your precious help to
12
5515
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 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
6
3946
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 open all four PPT files at once, and would loop through queriers for ever client and create custom presentations. Now there are 8 files, nearly 500 slides and the computer is bogging down with trying to open them all at once. I know that Access...
2
2609
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 don't know why it crash some time.
4
7666
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 handle the automation. So, i'm using the following code to create a new word document: ---Code---
0
6294
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 reformating, after the merge. This is a full description of my needs. I have a C# class library that creates two Crystal Reports, and then exports them to the harddrive as Word documents. One's orientation is landscape, the other is portrait. I then...
2
2617
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 course) which will merge the contents of files which I will point ie. 1.doc and 2.doc into one file: "12.doc" I've just tried to find smth in MSDN help, and in google archive of programing groups but still I don't know how to do it:(
4
11125
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 done this? Does it seem possible? I followed the instructions from a sample on the Microsoft knowledge base but it only seems to work when creating a VB.NET Windows .EXE, not an VB.NET ASP app.
5
2515
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 to have a word template on the server which is populated in the asp.net application and then streamed out to the user. Also acceptable would be to open a template on the client's computer using automation and fill this file (if this is possible)....
1
2904
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 when i add the code for inserting header;an error apear instead of header in the document the error is this:Error! Bookmark not defined. and this is the piece of code i added for inserting header:
0
7999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7931
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8423
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8067
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8281
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3911
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1270
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.