MS Word how to connect :)

R

Radek

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:(
I found that I can use WORD COM or using VBA (Swierszcz and Konrad ideas)
but still it is not working :(

have U got maybe such problem ?
If You resolved it Could U help me ?

Thank You very much

Best regards
Radek
windows messenger: (e-mail address removed)
 
B

Bob Grommes

Sounds like you'd have to use ActiveX Automation to control Word.

Is your application target more than one machine on which different versions
of Word might reside? If so, you have to contend with API and behavior
differences between different Word versions.

If you have control of the target machine(s) and can dictate that the most
recent version of Word must be used, then there is a primary interop
assembly for Word provided at no charge by Microsoft -- Google on PIA or
"Primary Interop Assembly", plus Word. You might haunt the sites and
discussion lists pertaining to Office development as well.

If you have an older version of Word then you can just have VS generate an
Interop assembly for Word, but if you try to do anything non-trivial you may
well end up dealing with version-specific quirks, from what I've heard. For
sure, your automation code would have to be tested against every version of
Word that you might have to talk to.

Another possible avenue exists. The most recent version of Word can save a
document as XML. This XML format is publicly documented by MSFT. You can
parse and transform it like any other XML document. The downside is, the
XML format is huge and complex; also, you may not be able to get the
producer of the original documents to save in that format reliably (though
you could use Automation to open a native Word document and save as XML as a
first step).

I have not actually had to do any of the above stuff yet (knock on wood) but
from what I've read it's all way more tricky than it ought to be.

--Bob
 
R

Radek

Is your application target more than one machine on which different
versions of Word might reside?

No, I have only one version of Word (MS Word 2002) and it's exactly like You
say:)
I need to write this application to automate some prosseses. Becouse I don't
want to open 2 or 3 or more Word documents and then copy to clipboard the
content for everyone and then create one document.
If you have control of the target machine(s) and can dictate that the most
recent version of Word must be used, then there is a primary interop
assembly for Word provided at no charge by Microsoft -- Google on PIA or
"Primary Interop Assembly", plus Word. You might haunt the sites and
discussion lists pertaining to Office development as well.

Thank YOU :) I will check it :) I think this is the solution :) I've just
also found smth like this:
http://msdn.microsoft.com/office/un...ary/en-us/odc_vsto2003_ta/html/wordobject.asp
but I havent read it all so far:)
About all my success or defeat I will write :)
The most recent version of Word can save a document as XML.
mine doesn't have :(
I have not actually had to do any of the above stuff yet (knock on wood)
but from what I've read it's all way more tricky than it ought to be.

--Bob

Yes, I agree with You in 100% :(
but once more Thank You - and now I'm goint to learn about what You've
written for me:)

Best regards
Radek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top