Saturday, March 24, 2012

OLE Automation by Javascript

i wrote this js function in HTML:

function OpenWord()
{
var a = new ActiveXObject("Word.Application"); a.Visible = true;
a.WindowState = 1; window.blur(); a.Activate();
}

if the it runs at localhost, it is OK, but it fail to create object when
running at other client. ( The same Office suite was installed in server &
client).

How to create a new WORD document ? Any ideas in operating VBA on
ActiveXObject? thanks.

Kosic.Hi,

It's generally a wrong thing to do. Office automation objects are not marked
as safe for scripting and therefore an attempt to access such objects from
client-side Javascript will result in denied access unless the website is
being opened in the My Computer zone (which happens when you test the
JavaScript on your development PC).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Kosic" <kosic@.sina.com> wrote in message
news:OGYLTr3nDHA.2772@.TK2MSFTNGP12.phx.gbl...
> i wrote this js function in HTML:
> function OpenWord()
> {
> var a = new ActiveXObject("Word.Application"); a.Visible = true;
> a.WindowState = 1; window.blur(); a.Activate();
> }
> if the it runs at localhost, it is OK, but it fail to create object when
> running at other client. ( The same Office suite was installed in server &
> client).
> How to create a new WORD document ? Any ideas in operating VBA on
> ActiveXObject? thanks.
> Kosic.
"Dmitriy Lapshin [C# / .NET MVP]" <x-code@.no-spam-please.hotpop.com> wrote in message news:<#HVY7P4nDHA.1488@.TK2MSFTNGP12.phx.gbl>...
> Hi,
> It's generally a wrong thing to do. Office automation objects are not marked
> as safe for scripting and therefore an attempt to access such objects from
> client-side Javascript will result in denied access unless the website is
> being opened in the My Computer zone (which happens when you test the
> JavaScript on your development PC).
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
> http://x-unity.miik.com.ua/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE
> "Kosic" <kosic@.sina.com> wrote in message
> news:OGYLTr3nDHA.2772@.TK2MSFTNGP12.phx.gbl...
> > i wrote this js function in HTML:
> > function OpenWord()
> > {
> > var a = new ActiveXObject("Word.Application"); a.Visible = true;
> > a.WindowState = 1; window.blur(); a.Activate();
> > }
> > if the it runs at localhost, it is OK, but it fail to create object when
> > running at other client. ( The same Office suite was installed in server &
> > client).
> > How to create a new WORD document ? Any ideas in operating VBA on
> > ActiveXObject? thanks.
> > Kosic.

I have also had a similiar problem and in addition to the advice
provided by Dmitriy, you may want to try the following:

In the IE Browser, goto to Tools-->Internet options--> Security and
add the server to your list on trusted sites (when prompted, provide
http://yourmachinename as a trusted site). This helped me with my
problem.

0 comments:

Post a Comment