Baptong
Sep 22 2008, 02:01 PM
I am using this document.execCommand('SaveAs') and when I do document.execCommand('SaveAs', 'true', 'word_file.doc'), nothing happens. Anyone know how to save Web page as a Word document? Either as DOC or DOCX file extension.
groovicus
Sep 22 2008, 03:34 PM
You are using the right syntax. What does the rest of your code look like?
Baptong
Sep 22 2008, 04:32 PM
Well, to make it simple, my code looks like this in a nutshell
<html>
<head>
<title>
</title>
<script language="Javascript">
function save_as()
{
document.execCommand('SaveAs', 'true', 'word_file.doc')
}
</script>
<body>
<input type="button" value="Save Form to the Local PC" onClick="save_as()"></input>
</body>
</html>
That button does not function nor does it bring up the Save As window.
groovicus
Sep 22 2008, 04:37 PM
The code looks fine. So the stupid question is are you trying to run it in Firefox with script block on or anything like that?
Baptong
Sep 22 2008, 04:43 PM
No, I am running it in Microsoft IE 7. Have you tried my code yourself? I am hoping it may be a user error on myself.
groovicus
Sep 22 2008, 04:47 PM
I am getting this error:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.execCommand]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/Users/Public/Documents/test.html :: save_as :: line 8" data: no]
Baptong
Sep 22 2008, 04:59 PM
Well, that is ODD.........
When I run it in IE 7, I had to allow the blocked content, and then I click on my button and nothing happens. Anyone else know something else? Or maybe even another forum where I can ask.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.