Create WordML via XSLT with embedded macros

M

Martin Leim

I have some XML file and want to transform it into Word(Processing)ML via
XSL-Transformation. I want to include some vba macro in it which runs when
the document is opened.
By looking at a WordML document with macros in it I learned that the macro
is embedded via base64 encoded binary data and in the word document header
there is a flag indicating we have embedded macros.

Now I copied this piece of binary code into my xsl file and applied it to
the xml. Now I get an "Unknown Error" with reference to the line and column
(its somewhere in the binary data).

It maybe that I am missing something in my XSLT file.
If I use the XSLT Inference Tool to create a XSLT I don't get an error, a
security warning concerning macros is showing up, but no macro is executed
(and none is in the code editor).

So is there a (working!!) possibility to include a macro that really works
in my XSLT file? The macro is constant, it doesn't have to change, so it
would be OK tu use this binary piece of code.
But how can I include it the way it works?

Thanks in advance for anyone having an idea.
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?TWFydGluIExlaW0=?=,

Assuming we're discussing Word 2003, Professional version...

It works fine, here. The attribute w:macrosPresent="yes" must be in the
w:wordDocument element. And the set of tags
<w:docSuppData><w:binData w:name="editdata.mso">binary data here

has to follow the <w:styles> and precede the <w:docPr> sections. When I do
that, then apply the transform to an XML file using MSXML (or a .NET XML
class) then save the result as a file and open it in Word, the AutoOpen macro
fires correctly.

You can't get the macro to show up by applying the transform to an already
opened XML file, though, if that's what you've been doing.
I have some XML file and want to transform it into Word(Processing)ML via
XSL-Transformation. I want to include some vba macro in it which runs when
the document is opened.
By looking at a WordML document with macros in it I learned that the macro
is embedded via base64 encoded binary data and in the word document header
there is a flag indicating we have embedded macros.

Now I copied this piece of binary code into my xsl file and applied it to
the xml. Now I get an "Unknown Error" with reference to the line and column
(its somewhere in the binary data).

It maybe that I am missing something in my XSLT file.
If I use the XSLT Inference Tool to create a XSLT I don't get an error, a
security warning concerning macros is showing up, but no macro is executed
(and none is in the code editor).

So is there a (working!!) possibility to include a macro that really works
in my XSLT file? The macro is constant, it doesn't have to change, so it
would be OK tu use this binary piece of code.
But how can I include it the way it works?

Thanks in advance for anyone having an idea.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
M

Martin Leim

Hello Cindy,

wow, thank you, it's working now!

I'm not quite sure what I made wrong before but I guess either I haven't put
the block between <styles> and <docPr> or I put some whitespace at the end or
beginning of the bindata block (or possibly both of it).

Anyway, thank you very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top