Automation of Word from .net 2

L

liya.tansky

Hello,
I'm developing an intranet (win XP, .NET 2, Visual Studio 2005,
Microsoft.Office.Interop.Word.dll in references) and needed to
implement find-replace in word doc before sending letter and it worked
fine on my station.
I've go it fine on my station, and it doesn't work at all on the web
server.
1. What should be the configuration of the server? There is .net SDK
2 and I've installed the oxppia.exe there. And changed the permissions
in DCOMCNFG for Word doc for ASP.NET user.
Should I also install there Offce XP?

2. Do I undestand correctly, that using Office 2003 will require
purchasing VSTO also?

PLEASE answer my questions, I'm completely lost and we planned on
starting to work with the site next week.

Thanks in advance
 
M

Mark Rae

I'm developing an intranet (win XP, .NET 2, Visual Studio 2005,
Microsoft.Office.Interop.Word.dll in references)

Firstly, you really need to understand that server-side automation of Office
is not recommended at all to the extent that Microsoft won't actually
support any application which uses it:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

If you absolutely *have* to use Microsoft Word for what appears to be a
fairly simple mail function, then you need to consider a 3rd-party solution
like this:
http://www.aspose.com/Products/Aspose.Words/Default.aspx

There are several other possible solutions:

1) Create the email as an HTML document. If you save it and give it a .doc
extension, Word will open it just like a native Word document

2) Use this:
http://www.microsoft.com/downloads/...52-3547-420a-a412-00a2662442d9&displaylang=en

3) If your email absolutely has to be in the form of an attachment, consider
using a PDF document instead of a Word document.
 
L

liya.tansky

Thank you for your quick answer.

My requirements are very strict.
The intranet will be used with existing docs, so PDF is not an option.
The client wants to send word only (not html) because his clients
requests word.
3-rd party is not also an option :(

So I need to use Word.

Do I need Office on the server for the automation? Will Office XP
answer my problems?

I'm asking also about Office 2003 and VSTo (if it is a must or not for
office 2003) , since the system administrator at my client's office
have installed Office 2003 on the web server and it surely didn't help
me, since I'm using xp redistributables. Tried ti switch to Office
2003, but couldn't find any article about web sites without mentioning
VSTO, so I'm just lost and very stressed on this.
Sorry for the simple questions.
 
L

Luke

Thank you for your quick answer.

My requirements are very strict.
The intranet will be used with existing docs, so PDF is not an option.
The client wants to send word only (not html) because his clients
requests word.
3-rd party is not also an option :(

So I need to use Word.

You will need office on the server but as Mark pointed out you
shouldn't use Office automation on a webserver, I had the same issue
as you (tho I needed excel) from a server. After looking into and
having the problems which office automation has from aspnet it was
cheaper and easier to use the Aspose library. The cost, trouble and
lack of support of server side office automation means you should stay
clear of it (remebering you will require a license to install office
on the server). It is cheaper and far easier to go the 3rd party
route.

why is 3rd party not an option? If it's cost then IMO it would be
cheaper to purchase the aspose library and get something you know will
work and is supported.
 
M

Mark Rae

The client wants to send word only (not html) because his clients
requests word.

You might find that they'd never know the difference! If they receive an
email with an attachment called e.g. Document.doc, what would they care if
it's actually an HTML document or a Word document...? When they click it, it
will display in Word just like a native Word document...
So I need to use Word.

Best of luck, then...
Do I need Office on the server for the automation?

Probably - how many licenses have you got...?
Will Office XP answer my problems?

I have no idea...
I'm asking also about Office 2003 and VSTo

Hasn't that already been discontinued...?
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1006730&SiteID=1
since the system administrator at my client's office have installed Office
2003
on the web server
Wow!

so I'm just lost and very stressed on this.

I appreciate that. However, you asked for advice and I gave it - I can't
help it if it's not what you wanted to hear...

You say you're stressed now - if you do go down this route, I can guarantee
you're going to get a lot more stressed as soon as your site goes live...

Office automation is not designed for this scenario. Please read the
Microsoft article again:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
 
L

liya.tansky

Thank you for your time.
Unfortunately, I have given documents that I need to send more then
once with different changes ( to different clients),
so I'll continue with the headache :))

THank you again
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

There are many ways to generate Word documents without using COM automation
on the server (which is not recommended.)
Here are more details on generated Word (and Excel) documents:
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/articles/ExportPanel.aspx

Here are some decent 3rd party options that can help with opening existing
Word docs and modifying the content before sending it out:
http://SteveOrr.net/reviews/AsposeWord.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx
 
M

Mark Rae

Unfortunately, I have given documents that I need to send more then
once with different changes ( to different clients),

You really don't get it, do you...?
so I'll continue with the headache :))

It's going to get much, much worse once your site goes live - you do *know*
that, don't you...?

I wonder how your clients would feel about you if they knew that you are
continuing to pursue a development strategy which in all likelihood will not
work properly...?
 
M

Mark Rae

There are many ways to generate Word documents without using COM
automation on the server (which is not recommended.)

The OP has already been given these recommendations but has chosen to ignore
them in favour of COM automation in the full knowledge that there is more
than a good chance that it will not work...
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

Mark,

I agree with you that it's not a good idea.
But, it could work if his scalability requirements are VERY low and he has
excellent error recovery in place...

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net


Mark Rae said:
Unfortunately, I have given documents that I need to send more then
once with different changes ( to different clients),

You really don't get it, do you...?
so I'll continue with the headache :))

It's going to get much, much worse once your site goes live - you do
*know* that, don't you...?

I wonder how your clients would feel about you if they knew that you are
continuing to pursue a development strategy which in all likelihood will
not work properly...?
[/QUOTE]
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

Mark,

I agree with you that it's not a good idea.
But, it could work if his scalability requirements are VERY low and he has
excellent error recovery in place...
 
M

Mark Rae

I agree with you that it's not a good idea.
But, it could work if his scalability requirements are VERY low and he has
excellent error recovery in place...

Of course - but surely nobody in their right mind would ever contemplate a
solution which only "could" work...?
 
J

John Timney \(MVP\)

I agree. I have done a lot of work with word automation from within asp.net
and its not a good idea at all.

The only safe way is to queue the jobs in asp.net and work out a way of
processing them singularly, within a desktop environment where it belongs.
Create some form of wordserver application that can access the data on the
asp.net server and seperate the activities.

--
--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
 
M

Mark Rae

I agree. I have done a lot of work with word automation from within
asp.net and its not a good idea at all.

I have a feeling none of this will make very much difference to the OP,
though...:)
The only safe way is to queue the jobs in asp.net and work out a way of
processing them singularly, within a desktop environment where it belongs.
Create some form of wordserver application that can access the data on the
asp.net server and seperate the activities.

Unless the documents are incredibly complex, I've always found the HTML
approach to be the most efficient - give it a .doc extension, and the
recipient of the email will have no idea that it's not a native Word
document...
 
L

Luke

approach to be the most efficient - give it a .doc extension, and the
recipient of the email will have no idea that it's not a native Word
document...

Couldn't another possibility be to use Word 2007 format, since it's
xml based this should cause no problems and allow the OP to write the
code themselve instead of using 3rd party (still far too much work and
time than needed). Of course this would require either Office 2007
installed on the client or the docx plugin for Office 2003. Tho the
requirement for it to work with existing documents would probably make
this not an option.

I don't get people who ask for advice and never listen to it.
 
M

Mark Rae

Couldn't another possibility be to use Word 2007 format, since it's
xml based this should cause no problems and allow the OP to write the
code themselve instead of using 3rd party (still far too much work and
time than needed).
Yes.

Of course this would require either Office 2007 installed on the client
or the docx plugin for Office 2003. Tho the requirement for it to work
with existing documents would probably make this not an option.

Depends on your perspective, I guess...
I don't get people who ask for advice and never listen to it.

It's incredible...
 
L

liya.tansky

not very nice I'd say.
learnt a lot from the discussion and 'll try to change as much as I
could.
but one thing: I'll try to stay away from the groups, didn't like your
approach of "go to the corner".
You should be very proud of yourself being an expert. I've just asked
about something that never touched and never heard before.

on the over hand, why am I bothering teaching someone manners?
 
L

liya.tansky

I do listen, I just don't have the money for 3rd party and licences
for Office (xp and 2003) already purchased.
We planned to start using the automation and then to choose our
strategy, since there are many limitations of time
Also we are talking about intranet (not more then 30 users).
I'll have a hardtime persuading the client to switch the strategy
right now.
 
L

liya.tansky

Hi, thank you for your answer.
unfortunately investing more money right now is not an option for my
client,
so it might happen that Office is the only choise right now.
I'm checking your exmples
 
L

liya.tansky

hi, thank you for your answer.
Could you please point me to some articles explaining your advise?
It would be of great help.
Sorry for the late answer , didn't see your answer before.
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top