This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes add value to a cell of  a ms word table using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "add value to a cell of  a ms word table using javascript" Watch "add value to a cell of  a ms word table using javascript" New topic
Author

add value to a cell of a ms word table using javascript

trivendra challa
Greenhorn

Joined: May 22, 2012
Posts: 3



I have a file whic is exporting from jsp page to my desktop and I am opening that using javascript.
while i am opening that file I have add a table as header to '.doc' file which was opened as i told earlier.
in that table I have rows and cells.
Now my problem is ...,How can I add value to specific cell using this javascript.I dont want to use,
vb script.please tell me a best solution to this.I am ataching code my code,below.

<script type="text/javascript"> /*to open document by double click on
corresponding ms word document.*/
var objWord;
var objDoc
var objSelection;
var tbl;
objWord = new ActiveXObject("Word.Application");
objDoc = objWord.Documents.Add("http://<%=request.getServerName()+":"+request.getServerPort()%>/qms/loaddoc/<%=docid%>.<%=ftype%>");
objWord.Visible = true;
objSelection = objWord.Selection;
tbl = objDoc.Tables.Add(objWord.Selection.Range,1,4);
var ccell = tbl.cell(1,2).range;
ccell.Font.Bold = false;
ccell.Font.Size = "5";
ccell.innerHTML =objWord.Selection.TypeText("Company Name:"+"<%=Compbean.getCompName()[0]%>");
//objWord.Documents.Open("http://<%=request.getServerName()+":"+request.getServerPort()%>/qms/loaddoc/<%=docid%>.<%=ftype%>");
</script>
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Welcome to CodeRanch!

You can't. JavaScript isn't able to interact with the Word document. You'd have to use VBScript or ActiveX or something like that.

Why don't you want to use VBScript?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
trivendra challa
Greenhorn

Joined: May 22, 2012
Posts: 3
Thank you Jeanne,

Now, I am able to to do that one by hTbl.Cell(1,2).Range.InsertAfter("<%=Cmpbean.getCompName()%>");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add value to a cell of a ms word table using javascript