PC Review


Reply
 
 
lsg
Guest
Posts: n/a
 
      28th Nov 2007
Hi,
Anybody know how to open docx (MS Word) file, retrive all formfields,
insert text and print in c# ?

Best Regards
Leszek
 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      28th Nov 2007
You have two choices:
1) use the Word Object model by setting a COM tab reference to the
appropriate version of Word.

2)Since docx files are XML, parse the Xml with the Office Xml APIs:

http://msdn2.microsoft.com/en-us/library/ms406049.aspx

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com



"lsg" wrote:

> Hi,
> Anybody know how to open docx (MS Word) file, retrive all formfields,
> insert text and print in c# ?
>
> Best Regards
> Leszek
>

 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      29th Nov 2007
On Nov 28, 2:10 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> You have two choices:
> 1) use the Word Object model by setting a COM tab reference to the
> appropriate version of Word.
>
> 2)Since docx files are XML, parse the Xml with the Office Xml APIs:
>


Docx files are not xml. They are zip files that contain the xml
files. To open them and manipulate their contents, the OP will want
to look at the System.IO.Packaging namepsace from .NET 3.0 and above.

--
Tom Shelton
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      29th Nov 2007
Tom Shelton wrote:
> On Nov 28, 2:10 pm, Peter Bromberg [C# MVP]
> <pbromb...@yahoo.NoSpamMaam.com> wrote:
>> You have two choices:
>> 1) use the Word Object model by setting a COM tab reference to the
>> appropriate version of Word.
>>
>> 2)Since docx files are XML, parse the Xml with the Office Xml APIs:

>
> Docx files are not xml. They are zip files that contain the xml
> files. To open them and manipulate their contents, the OP will want
> to look at the System.IO.Packaging namepsace from .NET 3.0 and above.


On older .NET versions it should be possible to use #ZipLib to
get a Stream and use that by XmlDocument Load.

Arne
 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      29th Nov 2007
On Nov 28, 7:30 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
> Tom Shelton wrote:
> > On Nov 28, 2:10 pm, Peter Bromberg [C# MVP]
> > <pbromb...@yahoo.NoSpamMaam.com> wrote:
> >> You have two choices:
> >> 1) use the Word Object model by setting a COM tab reference to the
> >> appropriate version of Word.

>
> >> 2)Since docx files are XML, parse the Xml with the Office Xml APIs:

>
> > Docx files are not xml. They are zip files that contain the xml
> > files. To open them and manipulate their contents, the OP will want
> > to look at the System.IO.Packaging namepsace from .NET 3.0 and above.

>
> On older .NET versions it should be possible to use #ZipLib to
> get a Stream and use that by XmlDocument Load.
>
> Arne


Sure - it should definately be possible. If you change the name of a
docx file to name.zip, you can actually open it with windows explorer,
just like a normal zip archive.

--
Tom Shelton
 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      29th Nov 2007
Good poiint, and I have done this several times. Should have said "zipped
xml"!

--Peter
"Inside every large program, there is a small program trying to get out."
http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://www.blogmetafinder.com



"Tom Shelton" wrote:

> On Nov 28, 7:30 pm, Arne Vajhøj <a...@vajhoej.dk> wrote:
> > Tom Shelton wrote:
> > > On Nov 28, 2:10 pm, Peter Bromberg [C# MVP]
> > > <pbromb...@yahoo.NoSpamMaam.com> wrote:
> > >> You have two choices:
> > >> 1) use the Word Object model by setting a COM tab reference to the
> > >> appropriate version of Word.

> >
> > >> 2)Since docx files are XML, parse the Xml with the Office Xml APIs:

> >
> > > Docx files are not xml. They are zip files that contain the xml
> > > files. To open them and manipulate their contents, the OP will want
> > > to look at the System.IO.Packaging namepsace from .NET 3.0 and above.

> >
> > On older .NET versions it should be possible to use #ZipLib to
> > get a Stream and use that by XmlDocument Load.
> >
> > Arne

>
> Sure - it should definately be possible. If you change the name of a
> docx file to name.zip, you can actually open it with windows explorer,
> just like a normal zip archive.
>
> --
> Tom Shelton
>

 
Reply With Quote
 
Vitalii Symon
Guest
Posts: n/a
 
      25th Dec 2008
Not sure about printing but you can merge open xml (docx) document using invoke docx lib. It doesn't need COM or p/invoke + is free.

i used it in several projects and it worked well.

p.s. http://invoke.co.nz/products/docx.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When .docx arrives by email, it will only save as a .zip- how to retrieve the docx? Benny Microsoft Word Document Management 2 4th Apr 2010 12:41 AM
Hi i have Docx password protection, which i am uding in DOCX , whi ashokapex Microsoft Word New Users 0 8th Jan 2010 03:46 PM
.docx NSavage Microsoft Word Document Management 3 11th Jun 2009 09:37 AM
Error opening docx file embedded into another docx file jd_mn Microsoft Word Document Management 0 28th Apr 2009 10:31 PM
Opening docx hyperlink from within a docx file Mark Microsoft Word Document Management 0 17th Jun 2008 03:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:32 AM.