Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

doc to docx

4 views
Skip to first unread message

asp.net

unread,
Dec 31, 2007, 5:50:43 PM12/31/07
to
hello gents,
i have a similar thing to do. i am not much into .net yet. i am currently working on asp website which generates doc file on a fly. i now want to convert these doc to docx files. i am not sure this can be doable in asp vbscript. any help or advice on this is much appreciable.
thanks
ibrahim

Peter Duniho

unread,
Dec 31, 2007, 6:07:02 PM12/31/07
to

Assuming you don't want to write a full-blown file converter yourself (a
daunting task, to say the least), you'll have to use Word 2007 to do
this. You can automate it through .NET I believe, but you need the actual
Word program to create a .docx file.

How are you generating the .doc files in the first place? I suppose if
you've already got code that generates .doc files from scratch, it might
be within your resources to just write code to generate .docx files
instead, rather than trying to write code that's more general-purpose to
convert one to the other.

Pete

Nicholas Paldino [.NET/C# MVP]

unread,
Dec 31, 2007, 6:27:49 PM12/31/07
to
Just as a side note, you don't have to use Word 2007 to write DOCX
files. You can use the classes in the System.IO.Packaging namespace, as
well as any XML classes that you want to generate the XML content that is
zipped up in the DOCX files.

The new file formats in Office 2007 are just XML files that are packaged
together (for the most part) in a zip file. The classes in the
System.IO.Packaging namespace will help with forming the relations between
the documents (it's not just as simple as a straight up XML file). One of
the resons for the new file format was to make it easier to generate them in
server-side solutions like this.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com


"Peter Duniho" <NpOeS...@nnowslpianmk.com> wrote in message
news:op.t372h...@petes-computer.local...

Peter Duniho

unread,
Dec 31, 2007, 7:25:24 PM12/31/07
to
On Mon, 31 Dec 2007 15:27:49 -0800, Nicholas Paldino [.NET/C# MVP]
<m...@spam.guard.caspershouse.com> wrote:

> Just as a side note, you don't have to use Word 2007 to write DOCX
> files. You can use the classes in the System.IO.Packaging namespace, as
> well as any XML classes that you want to generate the XML content that
> is zipped up in the DOCX files.

Well, you don't have to use Word of any version to write any version of a
Word document. That should go without saying.

But you're going to be replicating a lot of effort if you try to write a
.doc-to-.docx converter. That was my point. It would be far easier to
just automate an instance of Word to do the work (assuming you can rely on
Word being installed, of course).

Pete

Nicholas Paldino [.NET/C# MVP]

unread,
Dec 31, 2007, 7:55:30 PM12/31/07
to
Well, yes, but if the sig of the OP is any indication (asp.net), he/she
is doing it in an ASP.NET environment, where automating Word is a bad idea.

Yes, you don't have to use Word to write a Word document, but writing a
document in the earlier formats was difficult to do as there was no standard
to code against, and third-party components that did so are prohibitive to
some (in terms of cost). Doing so without any tools other than a zip
library and an xml library is not as difficult (then again, difficult is a
relative term, so I suppose there are people whom it is easier for).

I agree that writing a doc->docx converter is a waste if you are already
automating Word, just change it to automate the new version and produce the
appropriate output. But if they are generating it from scratch, I can't
agree that automating word is the best idea if this is indeed, being run in
an ASP.NET environment.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com


"Peter Duniho" <NpOeS...@nnowslpianmk.com> wrote in message

news:op.t3754...@petes-computer.local...

Peter Duniho

unread,
Dec 31, 2007, 8:16:57 PM12/31/07
to
On Mon, 31 Dec 2007 16:55:30 -0800, Nicholas Paldino [.NET/C# MVP]
<m...@spam.guard.caspershouse.com> wrote:

> [...]


> I agree that writing a doc->docx converter is a waste if you are
> already automating Word, just change it to automate the new version and
> produce the appropriate output. But if they are generating it from
> scratch, I can't agree that automating word is the best idea if this is
> indeed, being run in an ASP.NET environment.

Well, I already did write that if they are generating the .doc file from
scratch, it would make more sense to just write the .docx file from
scratch. Frankly, if they are generating the .doc file from scratch, I
don't think that it makes sense to convert the .doc file regardless,
whether by automation or some other means.

I don't know enough about ASP.NET programming to know why automating Word
would be a bad idea, but assuming it's not _impossible_ to automate Word,
I still think that's a better solution than trying to write a
general-purpose .doc-to-.docx converter. Note that I write
"general-purpose" because if one is going to do something like take
advantage of knowing what the .doc input is going to look like, one
_definitely_ would be better off just generating the .docx from scratch,
based on whatever data was going to be used to generate the .doc file.

Basically, it seems to me that any solution involving the conversion of a
.doc file to a .docx file is not desirable. Whether by automation or
writing a converter from scratch, there are better alternatives. But
between the two undesirable options, I think automation is the quicker
path to a solution, even if it is inappropriate for the context. :) (And
again, that assumes it's possible...I judge from your response that it's
possible, just not preferred).

Of course, this whole thread begs the question of _why_ one needs to
convert from .doc to .docx. I realize the newer format is more open, but
if the original data is in .doc format already, in what context is the
output document going to be used in which .docx is a valid format but .doc
is not?

But of course, any time we start questioning _why_ someone asking a
question wants to do what they want, they get all indignant and insulted,
as if you, I, and everyone else have nothing better to do than to harass
people about what they're doing without any intent to try to help them.

So I guess I won't bother asking that question.

Maybe next year will be better...

Pete

Nicholas Paldino [.NET/C# MVP]

unread,
Dec 31, 2007, 8:30:34 PM12/31/07
to
Ahh, here we go. No debating what you said, just adding the KB article
that explains why using Office in a server app is a bad idea. Specifically,
it talks about ASP, but everything applies to ASP.NET as well:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;257757


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Peter Duniho" <NpOeS...@nnowslpianmk.com> wrote in message

news:op.t378i...@petes-computer.local...

Peter Duniho

unread,
Dec 31, 2007, 8:40:49 PM12/31/07
to
On Mon, 31 Dec 2007 17:30:34 -0800, Nicholas Paldino [.NET/C# MVP]
<m...@spam.guard.caspershouse.com> wrote:

> Ahh, here we go. No debating what you said, just adding the KB
> article that explains why using Office in a server app is a bad idea.
> Specifically, it talks about ASP, but everything applies to ASP.NET as
> well:
>
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;257757

Yup. Sounds like writing a .docx from scratch is the way to go. :)

Thanks for the info.

Pete

0 new messages