Tinderbox Forum

Create a proper template to export one note to formatted file readable by Microsoft Word

Give a hint how to write an export template to export one note at a time to a formatted file that could be opened by Microsoft Word. What I am looking for to export Memos from TB to Word with some scarce styling. Say I want all the header to be centered and formatted with Helvetica 14 Bold, and all other paragraphs styled with Helvetica 10 Regular. That’s all. Any suggestions appreciated.

Do you need a template at all? You can export any note, section, or selected set of notes directly to Word: File ▸ Export As Text ▸ doc.

The problem is that I like the formatting of notes with standard font and size. They are easy to read and edit, but then I need to transform them to corporate standard memos. I have to set different attributes to paragraphs in Word. I wonder if this could be done automaticaly during export.

$Text can be styled and then exported, but this becomes a manual process as the $Text styling can’t be set automatically. I also note you want a 1-to-1 note to exported file ration as you want to add these notes into Word one at a time. Using your examples above try a template like this:

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>^title^</title>
	<style>
		body {font-family: "helvetica neue", helvetica, sans-serif;}
		p {font-size: 1em;}
		.head {text-align: center; font-size:1.4em;}
	</style>
</head>
<body>
<p class="head">^title^</p>
^text^
</body>
</html>

Word can read HTML, so simply copy/paste the rendered text (preview pane, web browser, etc.) or import the exported file into Word.

Test file: notes-for-word.tbx (97.5 KB)

1 Like

Mark, million thanks! That’s exactly what I needed.

2 Likes

If you want more flexibility to swap CSS stylings and to be able to work on CSS in a note of their own, you can borrow the trick used by the built-in zero-config ‘preview’ temple (which is in /Hints) which has this code:

<style>
   ^text(/Hints/Preview/style, plain)^
</style>

This ^text^ line could equally be written, to give more clarity as:

^include($Text(/Hints/Preview/style),^text(plain)^)^

Either way, ensure the note is set to use plain unstyled $Text. The use of an export include ensures the CSS data is part of the exported HTML page whilst, by changing the source note called, enabling use of different CSS.

Also, if you do this a lot, as I do. You can create a template to send multiple notes to work at once. You can also you Pandoc to push the notes into work. Moreover, with a simple trick in HTML, you can get word to recognize the exported HTML heading styles, even custom headings. Something we can address later if people are interested.

Michael, thank you for your posts. They helped a lot. Transferring text styles in files from TBX to word is very important for me because I use Tinderbox to write texts and then publish them with Mellel or Word. By using templates I will not have to meddle with the styling in word processors which is a great time saver.

Yes, I would appreciate an easy explanation on how to use Pandoc. If there was such a lesson please send me a link.

I would be interested in a trick to get Word to recognise the heading styles. I face similar hurdles to @Sergey_Glukhov in exporting my notes with the right formatting to Word. Reformatting stuff in word takes time and is unproductive.
For larger document exports using Pandoc I know one can use a template .docx file and ask Pandoc to adopt the heading styles found in the template but I haven’t seen an example (perhaps my limitation) using Tinderbox that makes use of this.

Sounds good. I’ll make this a point to cover in my next Patreon session: Michael Becker is creating training materials and thought-leadership | Patreon, Octboer 21, 6:00 AM PST. Following that, I’ll try to make a post. Any and all are welcome to subscribe to my Patreon channel. Once I get some time (have a heavy client load right now, I’ll circle back on this topic).

It is not your limitation. It took me countless hours of Internet sleuthing over six months to figure it out and then a bunch of trial and error to get the template right. The short answer.

In your template, you need to wrap your text with a custom div <div custom-style="NameOfWordSytle"></div>. This wrapper needs to be on the outside, not the inside, of your tags.

One big limitation is that you CAN NOT format tables externally to Word, which is extremely annoying. Again, when I have time I’ll circle back.

Thank you @satikusala - I look forward to your future posting and examples.

I haven’t seen an example (perhaps my limitation) using Tinderbox that makes use of this.

This is a limitation of Microsoft Word, not Tinderbox.

2 Likes

100% agree!!! Note, I have a solution for this. I just need to get done with a project first.

1 Like