Pages: 1
Print
Author Topic: xft form - Getting ActiveDocument is undefined  (Read 2439 times)
russurquhart1
Member

Posts: 46


« on: May 14, 2014, 09:28:38 AM »

Hi,

I'm trying to debug someone else's code. They have the following macro:

<MACRO name="FindMissingXRef" key="" lang="JScript" hide="false"><![CDATA[
// Note must be in tags on view for this to work.
   nonmodalDlg = null;
         var XftCtrl = new ActiveXObject("XF.XFTForm");
         nonmodalDlg = XftCtrl.StartForm("C:\\Doczone\\Forms\\xRefErrs.xft", 0);
]]></MACRO>

When they go to run it, and i can duplicate this, they get a dialog with stating the ActiveDocument is undefined.

I've never used this, and didn't write this, but am pretty sure it did work at one time. Can anyone suggest what i should check to look at this?

thanks,


Russ


Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: May 14, 2014, 11:57:25 AM »

I think you will need to look at the code inside the XFT itself to see what's going on.
Logged
XMetaLOldTimer
Administrator
Member

Posts: 57


« Reply #2 on: May 15, 2014, 02:29:37 PM »

This macro is using the "advanced" way of running an XFT form versus the simply way via Application.CreateFormDlg API.  When using the advance way, you need to inject all top-level objects referenced by the script contained within the .xft form.  The simply way automatically injects Application, ActiveDocument, Selection, Documents, and ResourceManager for you.  Try changing the macro like this:

         var XftCtrl = new ActiveXObject("XF.XFTForm");
         XftCtrl.AddTopLevelObject("ActiveDocument", ActiveDocument);
         nonmodalDlg = XftCtrl.StartForm("C:\\Doczone\\Forms\\xRefErrs.xft", 0);

Regards,
Addam
Logged

Addam Smith, XMetaL Project Lead & Architect
JustSystems Canada Inc.
russurquhart1
Member

Posts: 46


« Reply #3 on: May 21, 2014, 08:38:59 AM »

Hi,

I gave that a shot but, at least on my machine, it didn't make a difference. The issue is that on some machines in our group, this macro is working, on others, like mine, it is not. I can't help but think that this might be a Windows 7/MS Office upgrade issue. But i need to find out more info!

Thanks for the suggestions.

Russ
Logged
Pages: 1
Print
Jump to: