Link to home
Start Free TrialLog in
Avatar of okcuser
okcuser

asked on

VBScript Word document code works server side but not client side

I have code the opens a word document from a template and populates some tables.  It works great if I run it on the web server, save the file, and email it to the client then delete the file (so they don't stack up on the server).  I would rather just open the document on the clients workstation (they all have word), populate it,  and let them save it where they want.  I found that changing my <% %> to <script language=vbscript></script> causes the word document to open on the client like I want.  The template opens, but it won't insert the text into the table.  Why does the exact same code work on the server, but not the client?

<SCRIPT LANGUAGE=VBScript>
Set objWord = CreateObject("Word.Application")  
objWord.Visible = true
Set WordDoc = objWord.Documents.Add("\\okctonerweb1\WebTemplates\IncidentExportWord_new.dot")

With WordDoc
.Tables(1).Cell(1, 1).Range.InsertAfter ("Test")
End With
</SCRIPT>
ASKER CERTIFIED SOLUTION
Avatar of joeposter649
joeposter649

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of okcuser
okcuser

ASKER

I understand the reasons for the server side, but is there a reason that it shouldn't be done on the client side?  This is a controlled internal application where all the users have word.  They need to be able to edit it in word when necessary.  For the most part they use the printable reports off the web application.  I just am not sure why the .tables code works for server side, but not client side.   Seems like if word is on both the server and the client it should work the same?
Avatar of okcuser

ASKER

Well, it looks like the problem isn't my tables code, but instead that I am trying to read querystring variables just above it.  So I guess my next question to ask will be how to get request.querystring variables into my client side vbscript.  
Avatar of okcuser

ASKER

Got it

<script language=vbscript>
myvar=<%=request.querystring("myvar")%>

...
</script>

I'd still be curious to know if there is a reason why the automation shouldn't be done on the client side.  Thanks for taking the time to help!