...

View Full Version : call ActiveXObject in javascript



dikdikdik
12-30-2008, 03:31 AM
I try to use Javascript inside Actionscript which call MS word to read document. But it error when I initial ActiveXObject. Here is my code

test.mxml

ActionScript Code:


<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
private var calledFromJSHandlerFunction:Function = calledFromJSHandler;
private function init():void{
html.addEventListener(Event.HTML_DOM_INITIALIZE, domInitialized);
html.location = "htmlwithJS.html";
}
private function domInitialized(event:Event):void{
html.htmlLoader.window.calledFromJSHandlerFunction = calledFromJSHandlerFunction;
}
private function calledFromJSHandler():void {
mx.controls.Alert.show("ActionScript called from JavaScript", "Alert");
}
]]>
</mx:Script>
<mx:HTML id="html" x="137" y="40" width="339"/>

</mx:WindowedApplication>


htmlwithJS.html



<html>
<script language="Javascript">
function loadworddoc(){
var doc = new ActiveXObject("Word.Application");
doc.Visible=false;
doc.Documents.Open("C:\Sam\Sam.doc");
var txt;
txt = doc.Documents("C:\Sam\Sam.doc").Content;
document.all.myarea.value = txt;
doc.quit(0);
}
</script>
<body>
<input type="button"
value="Load"
onclick="loadworddoc()">
<br />
<textarea name="myarea">test now</textarea>
</body>
</html>


The message is : ReferenceError: Can't find variable: ActiveXObject

Any one can give me some advice?

gnomeontherun
01-06-2009, 10:41 AM
Is this not Flex?

dikdikdik
01-17-2009, 02:31 AM
I find a greate solution in http://aperture.fluorinefx.com/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum