Client side Automation

G

Guest

I have tried a server-side automation and it's giving me problems that I
couldn't solve..
Now, I'm switching to client side automation and I was following this example:
http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp
but to get it working I had to "Go to the Security tab, select Local
intranet, and click on the Custom Level button. Find the setting titled
"Initialize and script ActiveX controls not marked as safe" and change the
selection either to Enable or Prompt."
but this application will be distributed for different clients and I can't
keep doing this in every machine to get it work!? is there a solution for
that?


Cheers
 
M

Mark Rae

I have tried a server-side automation and it's giving me problems that I
couldn't solve..

Indeed, because Office is not designed to work this way to the extent that
Microsoft will not support any application which tries to do it:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
There is one simple reason why Microsoft doesn't support server-side
automation - it doesn't work! :)
Is there a solution for that?

There is no need whatsoever to use Office Automation in ASP.NET - several
alternatives exist...

What are your requirements for interfacing with Office files...?
 
S

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

No, there is no graceful solution if your application is to be widely
distributed. That's why client side automation is really only feasible for
small to moderate sized Intranet apps.

You'll probably want to use one of the other techniques I mentioned in the
article (but not server side automation.)

If you need to do anything fancy you could save yourself time and headaches
by using one of these 3rd party components:
http://SteveOrr.net/reviews/AsposeExcel.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx

Or here's a free control I made that might be of use to you depending on
your requirements:
http://SteveOrr.net/articles/ExportPanel.aspx

Another option is to open an existing Excel file and modify it as an ADO.NET
data source:
http://groups.google.com/group/micr...14d90e974e5/571439ff12d7473d#571439ff12d7473d
 
G

Guest

I'm trying to Mail merge an existing word documents and then save them
document somewhere.
I can't buy "Aspose" and I don't think there a free option for that, that's
why I'm trying client-side automation.
Steve has posted this link as Microsoft's free solution:
http://msdn2.microsoft.com/en-us/office/aa905533.aspx
but I don't know how it work or if it would work for office xp (v2002)!?
 
M

Mark Rae

I'm trying to Mail merge an existing word documents and then save them
document somewhere.

No problem.
I can't buy "Aspose" and I don't think there a free option for that,
that's
why I'm trying client-side automation.

You don't need client-side automation for this - see below...
Steve has posted this link as Microsoft's free solution:
http://msdn2.microsoft.com/en-us/office/aa905533.aspx
but I don't know how it work or if it would work for office xp (v2002)!?

VSTO works only for Office 2003 and 2007...


Fortunately, you don't need automation to create Word documents - you simply
use the HTML format.

1) Open up Notepad and paste the text below:

<html>
<head>
</head>
<body>
Hello World!
</body>
</html>

2) Save the file with a .doc extension, not a .txt extension, e.g. Word.doc

3) Double-click the file you just saved - Word opens it and displays it just
like a "native" Word document - it's highly likely that your users will
never know that it isn't...


So, instead of trying to create documents with MailMerge, create them with
HTML instead...
 
G

Guest

Yes, I've heard about this option before but:
First: I don't know how to create an html file from asp (code behind)
Second: I have to dynamically generate a table in my word document, and I
don't know how could I dynamically generate a table in the html document!!?


Cheers
 
M

Mark Rae

First: I don't know how to create an html file from asp (code behind)

I'm assuming that by 'asp' you actually mean ASP.NET, not ASP, so:
http://msdn2.microsoft.com/en-us/library/d62kzs03.aspx
Second: I have to dynamically generate a table in my word document, and I
don't know how could I dynamically generate a table in the html
document!!?

string strWord = String.Empty;
strWord += "<html>";
strWord += "<head>";
strWord += "</head>";
strWord += "<body>";
strWord += "<table>";
strWord += "<tr>";
strWord += "<td>";
strWord += "Hello";
strWord += "</td>";
strWord += "<td>";
strWord += "World";
strWord += "</td>";
strWord += "</tr>";
strWord += "</table>";
strWord += "</body>";
strWord += "</html>";

Or you could use the StringBuilder classs:
http://msdn2.microsoft.com/en-us/library/system.text.stringbuilder.aspx
 
G

Guest

Yes, thank u very mutch Mark I'm using this code and its working:
string path = @"c:\MyTest.doc";
if (File.Exists(path))
{
File.Delete(path);
}
FileStream fs = File.Create(path);
string strWord = String.Empty;
strWord += "<html>";
strWord += "<head>";
strWord += "</head>";
strWord += "<body>";
strWord += "<table>";
strWord += "<tr>";
strWord += "<td>";
strWord += "<B>";
strWord += "Hello";
strWord += "</B>";
strWord += "</td>";
strWord += "<td>";
strWord += "World";
strWord += "</td>";
strWord += "</tr>";
strWord += "</table>";
strWord += "</body>";
strWord += "</html>";
Byte[] info = new UTF8Encoding(true).GetBytes(strWord);
fs.Write(info, 0, info.Length);
fs.Close();
But the only issue is that when opening the created document, Ms Word will
pop up a message that I have to install a converter to be able to open it an
I did install it and the second message was warning me that "the current
document contains a non word components that may cause problems" and I
clicked OK anyway and the document did open.
Is there anyway to avoid those messages, or is this the way it will be!!!?
 
M

Mark Rae

But the only issue is that when opening the created document, Ms Word will
pop up a message that I have to install a converter to be able to open it
an
I did install it and the second message was warning me that "the current
document contains a non word components that may cause problems" and I
clicked OK anyway and the document did open.
Is there anyway to avoid those messages, or is this the way it will be!!!?

Puzzling - I've just run your code unmodified, and I was able to open the
resulting Word document without any warnings...

Do you have an "unusual" installation of Word...?
 

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

Similar Threads


Top