Macro in Macro
Asked by Christian Sprenger:

Can I create a user macro, which includes a macro with content?

**Example**

We have several documents, where we want to have a page-info with some content (table) for PDF export (Scroll PDF Export).

Now, for our authors it is annoying to always create this macro, add the same content, resp. to copy-paste it from a different page.  
I also can not create a page and include the page to the document page, as the page info has always the same columns but mostly different content (document numbers etc).

My idea is to create a user macro, which the author can use, which adds the page info macro with the table already prepared. Kind of a template.

Has someone a sample user macro or can guide me to the direction?  
I found some parts, but this does not work at all.  
Maybe it does not work, I do not know.

Thanks for all replies :)


Answers:
author: Dominic Lagger
body: Hi [@Christian Sprenger](/t5/user/viewprofilepage/user-id/684046)

I think, this would be possible. I'm interessted, what kind of information you want to display?

Depending on the information you want to display, you can easily make a user macro and display the parameters in a table.

For example:

```
## Macro title: ABC
## Macro has a body: N
##

## This is an example macro
## @param a:title=A|type=boolean|desc=A
## @param b:title=B|type=boolean|desc=B
## @param c:title=C|type=boolean|desc=C


<table id="myTable">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
</tr>
<tr>
<td>$parama</td>
<td>$paramb</td>
<td>$paramc</td>
</tr>
</table>
```

**Include another macro**

To include another macro, you can copy paste the "Storage Format" of the macro, like:

```
<ac:structured-macro ac:name="cheese" ac:schema-version="1" ac:macro-id="efb2934d-2e16-4a01-88a9-890c8ac3ce11" />
```

This is the storage format for the "I like Cheese " macro. Just copy that into your user macro.

**How to get to the Storage Format?**

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/91940i572F15485DFFF0FF/image-size/large?v=v2&px=999 "image.png")

Hope this helps you a bit. If you have any further questions, let me know.

Regards, Dominic

comments: author: Christian Sprenger
body: Hello Dominic,

thanks for the fast reply.

When I see it correctly, this will create a user macro with a table and a macro.  
But this will be independent, right? I will then have a table and beneath (or above) the macro, correct?

What I want to achieve actually is the macro with already added content, like a template.

![PProperties.png](https://community.atlassian.com/t5/image/serverpage/image-id/91946i3764CCB877852A2D/image-size/large?v=v2&px=999 "PProperties.png")

This is the content I require (well, more rows, but as example I think it explains it)

So, how can I add content in the page properties macro which I embed in my user macro?


author: Dominic Lagger
body: I'm not quite sure I understand you correctly :)

I try to explain.

A user macro renders its content when viewing the page. So the user macro looks different in the view mode and the edit mode. In the edit mode, you can't add a "template table".

So for you, this would looks like this (I think):

**User Macro**

```
## This is an example macro
## @param title:title=Document Sub Title|type=string|desc=Document Sub Title
## @param number:title=Document Number|type=string|desc=Document Number
## @param release:title=Release Date|type=string|desc=Release Date




<table id="myTable">
<tr>
<td>Document Sub Title</td>
<td>$paramtitle</td>
</tr>
<tr>
<td>Document Number</td> 
<td>$paramnumber</td> 
</tr>
</tr>
<tr>
<td>Release Date</td>
<td>$paramrelease</td>
</tr>
</table>
```

**Edit Mode from the macro**

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/91951iDC1DEE042F954CF1/image-dimensions/471x288?v=v2 "image.png")

**Edit Mode of the page**

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/91952i9C605C117E1928F5/image-size/large?v=v2&px=999 "image.png")

**View Mode of the page**

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/91954iF5C3C1B9D2BBFE5D/image-size/large?v=v2&px=999 "image.png")

And if this is not the use case you want, I'm so sorry that I didn't understand you correctly...

Let me know it.

Regards, Dominic


author: Christian Sprenger
body: Hello Dominic,

well, I think, when I understand you correctly, that technically it does not work.

I require more a template for a user macro.

Imagine that:

You have 200 Documents and on every document you have to add a macro _Page Properties_ with a table inside the macro of properties (see picture above)

Instead of telling our author to add the page property-macro manually and to add the table manually with the exact same content on the left side of rows, I was thinking to have a macro, which implements exactly this: the page property macro with already prepared table with template content.

More like

![UMac.png](https://community.atlassian.com/t5/image/serverpage/image-id/91959iA98D4183857D1DBD/image-size/large?v=v2&px=999 "UMac.png")

Where, when I choose the User Macro, it adds the page properties macro with an embedded table.  
Well, and actually, the page properties is hidden, it is only used for the PDF-Export. :D

Actually, I'd have a second use case, but let's focus on this one ;)


author: Dominic Lagger
body: So I don't think this is possible with a user macro, I'm sorry...

What about a real template?


author: Christian Sprenger
body: You mean a Blueprint?

This works for new documents, that's true. I added that here already.

But we have loads of existing and I was hoping to solve it the easy way.

Anyway, was worth a try.

Thanks for supporting.


author: Dominic Lagger
body: Yes, a blueprint or a template. That's not the same.

Blueprints have index pages, can't be easily created and can't have predefined labels.

Yeah, sorry for not working this out.

Regards, Dominic


author: Christian Sprenger
body: No worries mate, thanks anyway for the useful information.  
I'm pretty sure I'll have need of that on a later stage :)

Maybe I have to "reopen" this question as for a second case, but I have to re-think that :)


Tags: macro