Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

Use VBScript in aspx page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David C - 18 Sep 2007 20:50 GMT
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
Mark Rae [MVP] - 18 Sep 2007 21:21 GMT
> 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?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GGIH_
en-GBGB220GB220&q=JavaScript+Word+ActiveXObject


Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

David C - 18 Sep 2007 22:06 GMT
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

>> Can I use VBScript in a aspx page similar to using Javascript for running
>> client code?
[quoted text clipped - 15 lines]
>
> http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GGIH_
en-GBGB220GB220&q=JavaScript+Word+ActiveXObject
Mark Rae [MVP] - 18 Sep 2007 22:41 GMT
> I tried this using the sample function below and got the error "Automation
> server can't create object"
[quoted text clipped - 6 lines]
> }
> }

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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

David C - 18 Sep 2007 23:28 GMT
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

>> I tried this using the sample function below and got the error
>> "Automation server can't create object"
[quoted text clipped - 12 lines]
>
> I strongly advise you not to do this...
Mark Rae [MVP] - 19 Sep 2007 00:30 GMT
> 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...?

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

David C - 19 Sep 2007 13:58 GMT
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

>> 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.
[quoted text clipped - 9 lines]
>
> What is the actual requirements here...?
Mark Rae [MVP] - 19 Sep 2007 14:26 GMT
>>> 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.
[quoted text clipped - 14 lines]
> 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.

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.