473,395 Members | 1,466 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,395 software developers and data experts.

Automate Word - File in Use error.

Hi,
I'm attempting to automate word to load a document. I have no problem if
Word isn't loaded yet as creating a new Word.ApplicationClass() loads it for
me. However, there will be times when Word is already loaded and I want to
connect to that copy (and check whether the document is already loaded).

When Word is already loaded, creating a new Word.ApplicationClass() loads
another copy of Word and tries to load my document again. I then get an
error message telling me the file is in use.

I'm having some problems working out how to get the ApplicationClass if an
already running copy of Word... anyone know how I do that?

Thanks
Steve
Nov 17 '05 #1
2 1661

"Steve Barnett" <no****@nodomain.com> wrote in message
news:Ob**************@TK2MSFTNGP15.phx.gbl...
Hi,
I'm attempting to automate word to load a document. I have no problem
if Word isn't loaded yet as creating a new Word.ApplicationClass() loads
it for me. However, there will be times when Word is already loaded and I
want to connect to that copy (and check whether the document is already
loaded).

When Word is already loaded, creating a new Word.ApplicationClass() loads
another copy of Word and tries to load my document again. I then get an
error message telling me the file is in use.

I'm having some problems working out how to get the ApplicationClass if an
already running copy of Word... anyone know how I do that?

Thanks
Steve


You should connect to the running instance using Marshal.GetActiveObject.

Willy.
Nov 17 '05 #2
That's terrific, thank you. I would never have gotten there!

I'm struggling so badly getting my head around the classes available to me
in C#... things were so much easier with VB6, where you have to do
everything yourself!

Steve

"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

"Steve Barnett" <no****@nodomain.com> wrote in message
news:Ob**************@TK2MSFTNGP15.phx.gbl...
Hi,
I'm attempting to automate word to load a document. I have no problem
if Word isn't loaded yet as creating a new Word.ApplicationClass() loads
it for me. However, there will be times when Word is already loaded and I
want to connect to that copy (and check whether the document is already
loaded).

When Word is already loaded, creating a new Word.ApplicationClass() loads
another copy of Word and tries to load my document again. I then get an
error message telling me the file is in use.

I'm having some problems working out how to get the ApplicationClass if
an already running copy of Word... anyone know how I do that?

Thanks
Steve


You should connect to the running instance using Marshal.GetActiveObject.

Willy.

Nov 17 '05 #3

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

Similar topics

1
by: haacked | last post by:
I am trying to automate the printing of an RTF file that contains watermark images in the header and am finding it very challenging. I looked at several articles about printing rtf docs using the...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
4
by: Ray Todd Jr | last post by:
I can't get ths code to correctly execute. After I have clicked on a Access Form, I want the code to open the word document, merge the data, print the forms and then close the two windows that...
1
by: Steve Barnett | last post by:
Hi, I'm attempting to automate word to load a document. I have no problem if Word isn't loaded yet as creating a new Word.ApplicationClass() loads it for me. However, there will be times when Word...
0
by: Vijay Neelam | last post by:
How can I automate Microsoft Word from ASP.NET. My requirement is like this I have Datagrid with checkboxes... I need to export checkbox selected rows into Microsoft Word. I tried to...
8
by: Vijay Neelam | last post by:
How can I automate Microsoft Word from ASP.NET. My requirement is like this I have Datagrid with checkboxes... I need to export checkbox selected rows into Microsoft Word. I tried to...
1
by: Vijay Neelam | last post by:
How can I automate Microsoft Word from ASP.NET. My requirement is like this I have Datagrid with checkboxes... I need to export checkbox selected rows into Microsoft Word. I tried to...
15
by: Karl | last post by:
Hi all, I regularly use FTP to place Self Extracting Zip files on the web for remote users to update their datafiles. Works very nicely. I have automated the creation of the initial zip file (...
7
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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.