473,659 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating/Saving MSWord documents from C# application

Hello NG,

Never used interOps for programming so for many this might be a very small
problem. Basically I have 2 questions --

1- Code given below creates WinWord.exe instance and even after application
terminate MS-Word is left open. If I use task manager to see how many
instances are created then one instance is created and terminates but other
stays. In other words, 2 instances are created and one is left active. I
know code is buggy but I don't know why is this happening. In my
understanding all the local objects (thus instances) should terminate after
leaving function.

2- Second problem is inlined in the code.

Thank you,
Po

//Ref: Microsoft Office 11.0 Object Library
private void LoadWord(object sender, System.EventArg s e)
{
Microsoft.Offic e.Interop.Word. ApplicationClas s oApp = new
Microsoft.Offic e.Interop.Word. ApplicationClas s();
object oMissing = System.Reflecti on.Missing.Valu e;
Microsoft.Offic e.Interop.Word. _Document oDoc = oApp.Documents. Add(ref
oMissing, ref oMissing, ref oMissing, ref oMissing);
// This is where I want to load value from DB column rather open a file
oDoc.Content.Te xt = "what a file";
string sString = @"C:\\file.doc" ;
object oString = sString;

// Here I want to save it into DB after changing the format to RTF
oDoc.SaveAs(ref oString,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,ref oMissing);

}
Nov 17 '05 #1
0 1039

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

Similar topics

1
1696
by: Eilsa | last post by:
I want to perform a full-text search for a lot of MSWord documents. So that I have to read the MSWord content and store it to the database. However, I cannot find any solution on it. What should I do if I want to perform a full-text search for these MSWord documents? or any alternative solution for me?? Thanks Best Regards, Eilsa
0
1270
by: staleb | last post by:
Hi I want to open a MSWord document on the clients PC/MSWord, the solution I use now is this: <script language=vbscript runat=Server> <!-- sub OpenDoc(strLocation) set objWord = CreateObject("Word.Application") objWord.Visible = true objWord.Documents.Open strLocation
5
1187
by: Y.A. | last post by:
I want to start msWord on the server with an a givene file (.doc), customize the file (update it) then display it on the client machine -- all this on intranet using asp.net. I know it's doable with some javascript using ActiveX -- is anyone aware for another way to do it
2
4529
by: Asha | last post by:
Greetings, I’ve query some data from the table, how can I push it into an excel file and allow user to save it? anyone done this sort of thing before?
0
1860
by: goof1972 | last post by:
Hello All, I have a VB.NET web application (1.1 framework) that creates a new Word document through interop.word.dll. I have a Windows Server 2003 with Office XP Professional installed. I've also installed the Office XP PIA. In my VB.NET application, I want to create a new Word document using the following code:
6
1820
by: Peter | last post by:
I have to write a ASP.NET application that creates MSWord document from a template and populated with data from the webpage. (Templates can reside on the server or client's hard drive.) What is the best way to do this? Is it good idea to have MSWord installed on the server? If it's not a good idea or if MSWord is not installed on the server what are the alternatives? I am using Office 2003. Thank You
4
1155
by: Gus | last post by:
We create reports in MSWord 2000 from within our Access 2002 application. The report template uses a lot of tables and nested tables. Over time, many hundreds of reports, Word has become difficult to use in a way that looks like a memory/display problem. In simple terms, the screen does not update when I change things in the document ie delete a line. Table borders do not display on the screen.
2
9428
by: ClearCut | last post by:
I have written a program in VB6 that opens an existing Word document and adds some text to the top of the document before printing it. Now I want to close the document without saving the changes. This preserves the document as a "templet". However it seems that it automatically saves the document with the changes prior to closing. Below is my code. Thanks in advance for your help. Dim strE As String Dim objWord As Word.Application ...
2
944
by: mikarzexela | last post by:
Hi, Newbie here, could you please help me link one of my tables to print in MsWord. from vb6 Dim obj_Word As Word.Application Dim obj_WordDoc As Word.Document Dim i_Loop As Integer On Error GoTo err_Handler Set obj_Word = CreateObject("Word.Application") Set obj_WordDoc = obj_Word.Documents.Add obj_Word.Visible = True
0
8427
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
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8626
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
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
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
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.