Solved

Starting Word from a server-side Javascript (ASP)

Posted on 2002-07-30
18
416 Views
Last Modified: 2007-11-27
Hello, I want to start/execute a server-side javascript, the problem is that I have not understood how the syntax works. I have windows 2000, and IIS installed, and the documents (asp-pages) resides in the wwwroot-directory.
Clients access a client javascript, and via the <form> tag triggers the asp-page which contain server-side javascript.

On the client script it looks like this:
<form name="myform" action="Server.asp" method="post">
<input type="submit" value="Create Document" name="knapp" onClick="validateAndSubmit()">
</form>

Here, as I understand it the page called Server.asp is "called". So far so good?

Now, how do you write the code for the server-side?
I have a version that looks like the lines below:
<server>    
     var word
     function ladda()
          {
               try {
                    word=new ActiveXObject('Word.Application.9') // word 2k
                    } catch (e) {
               try {
                    word=new ActiveXObject('Word.Application.8') // word 97
                    } catch (e) {
               try {
                    word=new ActiveXObject('Word.Application.7') // word 95
                    } catch (e) {
               try {
                    word=new ActiveXObject('Word.ProgID') // word 2k
                    } catch (e) { // Okay I give up, no word installed.
          }
          }
          }
          }

               // word = new ActiveXObject('Word.Application');
               word.visible = true;
               // var thedoc = word.Documents.Open("http://clibben/clickprocess/FTR_makroversion.doc");
              word.Run('Macro3');
              word.quit();      
          };
          ladda();
</server>

Where the last line is for calling the function ladda() (probably totally wrong :-)).

I would appreciate if someone could help me with this. As it is now, when the users push the button, they only see the text (in small black letters) on a totally white page.


Best regards
Harald
0
Comment
Question by:Niiii-Knight
  • 10
  • 3
  • 2
  • +3
18 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 7187968
instead of
<server>
do this:
<SCRIPT language='javascript' runat='server'>
0
 

Author Comment

by:Niiii-Knight
ID: 7188193
Ok, I have tried that and tried VB below, just to see if simple exmaple works.

<%
      Dim aword
      set aword = Createobject("Word.Application")
      aword.Visible = true
%>

However, in both cases I get the error message:
Call rejected by Callee

What I have read, this can be a bug with Norton Virus and Office 2000 (2002 it is fixed apparently). I do not have a officeav.dll, which they say you can take away by:
reg32 sr -u and so on. I have C:\ePOAgent\AgentDB\Data\NORTONAV7500\NAVPlug.dll which I could not do that on.

How the h-ll should this be fixed? Any solution would make me very happy.

Regards
Harald
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 7188210
The IUSR_MACHINENAME does not have sufficient rights to access the word application. You need to use either a user that HAS the rights or you use Component Services to set a user to that object 9which also has sufficient rights).

CJ
0
 

Author Comment

by:Niiii-Knight
ID: 7188529
Ok, unfortunaltely I´m lost of how to set rights for a user, or how to create user and so on. In simple terms, how do I do that? I can not find "set rights for user" in Computer Management??

Regards
Harald
0
 

Author Comment

by:Niiii-Knight
ID: 7190667
Ok, I have now investigated further and done the following:
First, I have set the web permissions for the IIS to be read and execute scripts. Then, regarding NTFS I have added
IUSR_computername and given it read, read and execute, and list folder rights for the www_root folder.

Still, access denied is shown if I try to access the web site from another computer.

Do I have to restart IIS to register new settings?
Do I have to mark som checkbox so that subfolders also get these rights?

Anyone with any ideas?

Regards
Harald
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7190767
Is office on the SERVER? Does the IUSR_machine account have rights to run apps on it? I doubt either is true, and most ESPECIALLY the IUSR_machine account NEVER has rights to run any apps that aren't specifically needed -- and Office isn't needed. It's rarely on the server to begin with for precisely that reason.

Are you SURE you want to run Word on the SERVER? Why? If you're submitting a FORM, Word would hardly be the best thing to use for it.

What EXACTLY are you trying to do?
0
 

Author Comment

by:Niiii-Knight
ID: 7190912
I would like for users to fill in information on a website, and push a button, and via server-work produce a mailmerge on Word and send that produced Word document to the client in question. That is, automate a boring task (I have marked fields in the header in Word documents/templates as merge fields, and via Excel data is exchanged in the header).

The code below produces the error: Call was rejected by the callee: (this asp-page is called from the client-script, and for the moment I am not passing any parameters. I do that later, for now I would like this to work).
<SCRIPT LANGUAGE=javascript RUNAT=server>      
     word = new ActiveXObject('Word.Application');
     word.visible = true;
     word.Run('Macro3');
     word.quit();      
 </SCRIPT>

I do the work on the server since otherwise I would have to lower security levels for the clients to recieve untrusted ActiveX objects, further, to minimize compatibiity issues.

Any idea how I can get this code to function?

Regards
Harald
0
 

Author Comment

by:Niiii-Knight
ID: 7190918
The web server is fixed now (I tried accessing another page, and it worked fine). Users can access pages. However, my problem described above with caller was rejected and so forth still exists!

Regards
Harald
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7192180
How are you going to name these files? What are you going to do with them AFTER you create them? You can't keep naming them the same thing -- if more than one person tries to use the form, they'll get an error.

Also, you DO realize that you're putting a HORRENDOUS load on the server? It very possibly will have multiple versions of Word running at one time, and be dealing with multiple files.

Why not just use the form info to generate a dynamic HTML file and let the users print that? That wouldn't strain the server the way Word will. What kind of file is this? Where is the rest of the mailmerge info coming from? If they're passing you all the required info, then generating an HTML file customized on that is easy. If the info comes from a database, it's also better to generate it using ASP directly, rather than going through Word.

I honestly don't think Word is the best tool for generating this type of thing...
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Niiii-Knight
ID: 7192725
I get this error message (even if I test it on the machine that the server resides on):
Error Type: 0x80010001, Call was rejected by callee

And if I look in the task manager winword processes are started (one for every try I make), and they can not be killed! It saysd "unable to open process" so I have to restart the computer when the winword processes tend to be too many.

Any suggestions?

Regards
Harald
0
 

Author Comment

by:Niiii-Knight
ID: 7192767
I thought of locking the server with lock, and unlock while a user accessess the server. The mailmerge is done with Excel, which will have two coulmuns with values that will be updated after each call.

The reason for doing it with Word is that they want it so. They fill in information in word, saves it and will store it on their computer. It is used when they do so called Functional Descriptions or Functional Specifications.

They want to automate a boring routine. So the routine will take place on the server, and when it is done the word document will be sent to the client.

I do word.quit() after each session and the number of users accessing the server will not be that great so I thought of testing this approach.


/Harald

0
 

Author Comment

by:Niiii-Knight
ID: 7192907
I have McAFee Virus Scan v4.5.1 SPI installed, not Norton. The boxes "Enable Java and ActiveX filter" is checked. The same thing at the client´s computer. However, when I did this on a client-side javascript, there was not any problem. It is a problem when a run the script as a server-side script.

Is there any settings in McAFee concerning restrictions on the web server (IIS in this case)? Could not find nothing useful.


Regards
Harald
0
 

Author Comment

by:Niiii-Knight
ID: 7193257
I marked the check boxes in IIS "enable server-side script debugging" och client side script debugging.
Then I got this message when I tried to run the server-side script:
"An exception of the type "Runtime error" was not handled.

Then it says if I want to debug the application, if I push yes it says:
"Devenv.exe - Application Error" at the top bar. Further down it says:
"The instruction at "0x78011601" referenced memory at "0x0000babe". The memory could not be "read".

Any suggestions?


Regards
Harald
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7194995
Yes. Don't use Word. I know it's not what you want to hear, but what they want isn't going to work. You can crash the server pretty fast doing that.
0
 

Author Comment

by:Niiii-Knight
ID: 7195403
You mean it is impossible to start Word from the server-side? All these expensive "hightect" systems and you can not start Word on a server? They put a man on the moon in the sixties so this ought to be done. Anyone else who has any tips on how Word can be started from the server (Windows 2000, IIS)?

Regards
Harald
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8334692
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or so. I appreciate any comments that would help me to make a recommendation.
 
In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care
 
ahosang
0
 
LVL 12

Expert Comment

by:ahosang
ID: 8528138
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8627071
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now