Pages: 1
Print
Author Topic: Macro code having no effect  (Read 371 times)
jmarkp
Member

Posts: 2


« on: August 02, 2011, 06:22:48 AM »

We're hosting the XMAX control (v. 6.0.0.159) via a Windows Form Host in a WPF application and it's mostly working fine.

I'm trying to write a macro to modify the paste behaviour, so I'm using On_Document_Before_DropText

The code is definitely being parsed, because if I introduce a JavaScript syntax error (missing a closing ')') then an error message pops up to that effect when I paste text.

However the code itself doesn't seem to be having any effect. Am I doing anything wrong?

Here's my .mcr file:

Code:
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">
<MACROS>
<MACRO name="On_Document_Before_DropText" lang="JScript" hide="false"><![CDATA[

var ActiveDocument = new ActiveXObject("XMWrap.XMActiveDocument");

ActiveDocument.Host.Alert("Your Message Here", "test");

]]></MACRO><MACRO name="On_Macro_File_Load" lang="JScript" desc="Macro executed when the macro file is loaded" hide="false"><![CDATA[// XMetal Author JScript Macro File
var Application = new ActiveXObject("XMWrap.XMApplication");
var Documents = new ActiveXObject("XMWrap.XMDocuments");
var ActiveDocument = new ActiveXObject("XMWrap.XMActiveDocument");
var Selection = new ActiveXObject("XMWrap.XMSelection");
var ResourceManager = new ActiveXObject("XMWrap.XMResourceManager");
]]></MACRO></MACROS>

Interestingly, if I rename Alert to Alrt no error message gets thrown, but if I remove the
Code:
var ActiveDocument = new ActiveXObject("XMWrap.XMActiveDocument");
line above it I do get a 'null object' error.
Logged
jmarkp
Member

Posts: 2


« Reply #1 on: August 02, 2011, 08:01:03 AM »

More information from more digging.

If I compile the On_Document_Before_DropText script into an XAC using XMetal Developer in Visual Studio then the script gets run. It's when I just add it manually to the MCR file that it doesn't get run. Very strange...

This seems to have solved my problem, thank goodness :)

Mark
Logged
Pages: 1
Print
Jump to:  

email us