Use VBScript in aspx page

D

David C

Can I use VBScript in a aspx page similar to using Javascript for running
client code? I assume it would be used in a <script> block. This is for a
controlled intranet internal application and I'd like to be able to use Word
objects using CreateObject() etc. Is that possible, and if so, where can I
find more info on it? Thanks.

David
 
M

Mark Rae [MVP]

Can I use VBScript in a aspx page similar to using Javascript for running
client code?
Yes.

I assume it would be used in a <script> block.
Yes.

This is for a controlled intranet internal application and I'd like to be
able to use Word objects using CreateObject() etc.

OK. Obviously, client-side VBScript runs only in IE - not a problem if you
control the browser, I guess...

Also, there's nothing you can do in VBScript as regards client-side Office
automation that you can't do just as well in JavaScript...

http://www.google.co.uk/search?sour...-GBGB220GB220&q=JavaScript+Word+ActiveXObject
 
D

David C

Mark,
I tried this using the sample function below and got the error "Automation
server can't create object"

function openWord( file ) {
var oword = new ActiveXObject("Word.Application");
if( oword!==null ) {
oword.Visible = true;
oword.Documents.Open( file );
}
}

David
 
M

Mark Rae [MVP]

I tried this using the sample function below and got the error "Automation
server can't create object"

function openWord( file ) {
var oword = new ActiveXObject("Word.Application");
if( oword!==null ) {
oword.Visible = true;
oword.Documents.Open( file );
}
}

That's almost certainly down to your browser's security settings, which
you'll need to ramp right down - incidentally, you'd get exactly the same
error in VBScript...

I strongly advise you not to do this...
 
D

David C

So what are my alternatives? My customer wants to be able to open a Word
document or template and fill in data from their web page.

David
 
M

Mark Rae [MVP]

So what are my alternatives? My customer wants to be able to open a Word
document or template and fill in data from their web page.

It's important to realise (and educate your client!) that one of the
fundamental design goals of web browsers is specifically to prevent *any*
sort of automatic interface with the hardware of the client machine and any
software installed on it, for fairly obvious security reasons...

Why not simply get the users to fill in all the details in your web page and
then create a Word document server-side using HTML, OpenXML or Aspose and
then stream it down to them?

What is the actual requirements here...?
 
D

David C

We are replacing an Access application with a web/SQL Server application.
One of the things done in Access is OLE automation doing data inserts into a
Word document (new and templates), possibly modifying the document text and
then saving/printing the letter.

David
 
M

Mark Rae [MVP]

We are replacing an Access application with a web/SQL Server application.
One of the things done in Access is OLE automation doing data inserts into
a Word document (new and templates), possibly modifying the document text
and then saving/printing the letter.

Access is a desktop application, same as Word is a desktop application.

ASP.NET isn't - it's as simple as that...

By far the simplest solution here would be to create the Word documents on
the server as I described, and then stream them down to the client either
directly in the browser or as files which they can save wherever they want
to save them and then edit them as they see fit.

Alternatively, you can save the documents on a network file server and then
provide a hyperlink for the users to click.
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top