473,473 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# VS2005 / Word Automation / Documents.Open closes open document

1 New Member
I am automating Word and getting the existing instance if available using the following:

Expand|Select|Wrap|Line Numbers
  1. Word.Application oWord = null;        
  2. Word.Document oDoc = null;
  3. object oMissing = System.Reflection.Missing.Value;    
  4. object sFN = @"C:\Test\TestDoc.doc";
  5.  
  6. try 
  7. {
  8.      // Is Word running? 
  9.      oWord = Marshal.GetActiveObject("Word.Application") as Word.Application; 
  10. }
  11. catch (COMException ce)
  12. {
  13.      if (ce.ErrorCode == unchecked((int)0x800401E3))
  14.        // No, Word not in ROT, start a new instance 
  15.        oWord = new Word.Application();
  16. }
And that is working just fine, and then I am opening a document with:


Expand|Select|Wrap|Line Numbers
  1. oDoc = oWord.Documents.Open(ref sFN,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,
  2.     ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,
  3.     ref oMissing,ref oMissing,ref oMissing,ref oMissing);
However, if I have a Word document already open when I do that my Open statement is replacing the open document with the one I am loading.

I have searched high and low and cannot find any reference to this behavior.

Anyone ever encountered this?

Thanks in advance...RK
Jun 19 '07 #1
0 2530

Sign in to post your reply or Sign up for a free account.

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...
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...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
4
by: Kash | last post by:
Hi everybody: I've developed a web application running on a 2003 server not on the web but on extranet environment of a small Firm (less than 10 users). I've taken benefit of Office Primary...
4
by: chandu | last post by:
Hello, i need to convert a word doc into xml format and need to store that xml doc in to a sqlserver database.. how to convert a word doc to xml and after retrieving that xml doc from database...
1
by: webgirl | last post by:
Hi everyone, I have a weird problem with some Word/Excel automation code that I run from Access (not sure if I should therefore post this in the Access forum..? Thought I'd try here first) ...
1
by: Derek Hart | last post by:
I have a vb.net winforms application that loops through several thousand word documents and prints them, with the filenames being read from a SQL database. I am using late bound code to load MS...
2
by: Derek Hart | last post by:
I am using late bound Microsoft Word integration with a vb.net winforms application. If I run code such as the following: Dim objWord As Object Dim objWrdDoc As Object Dim count As Integer...
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
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
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.