EvotecIT / PSWinDocumentation

PowerShell Module that creates Word/Excel/SQL documentation from Active Directory (AD), AWS, Office 365 and others. It's a work in progress!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom Template - Table of Content/Headding failed

ferwe opened this issue · comments

I tried to use a custom template for creating the report.

After a few tests the following happened

  1. If I use the internal Template, the Table of Content was created correctly
  2. If I use the internal Template but with the custom template option, it was created correctly as well
    This are the situations which worked

If I use a own template, the headding didn't work. So there are no headding where the Table of Content could relate to.
I tested following situations, which doesn't worked:

  1. I used a own template
  2. I copied the builtin template and put my own stuff in it
  3. I copied the builtin template and removed just the evotec background

I use Word 2016 for creating the template

I believe it's related to this: EvotecIT/PSWriteWord#16

I've reported this a while back in Xceed DLL. What you could try to do:

  1. Use PSWriteWord to create empty DocX (with TOC if needed) but you can just test without it.
  2. The goal here is to get those headings created by PSWriteWord
  3. Use Merge-WordDocument from PSWriteWord with your template
Merge-WordDocument -FilePath1 BlankPSWriteWord.docx -FilePath2 YourTemplate.Docx -FileOutput NewTemplate.docx

And let me know if it works. If it does then I can build workaround into PSWinDocumentation that does this for any custom templates. Thanks for reporting this.

I tried it, but unfortunately the merge-command doesn't worked like expected.
If I try
filepath1 "BlankWord"
filepath2 "myTemplate"
the output is a complete blank document and the headding works like expected.

If i try
filepath1 "myTemplate"
filepath2 "BlankWord"

the output is my template but the headding isn't working with the script.

btw.
My template has a picture in the header and some text in the footer area.

I also tried to load my template, add something and save it again.
Doesn't work as well.

What if you try to create an empty doc with PSWriteWord and add your stuff into it and load it?

Same result. Already tested :)

That’s weird because thats how I created my template. Care to send me your template? Publicly or privately via email? I’ll take a look

If you want to build documentation on your own template you're free to do so, however, you should use Data\EmptyDocument.docx as your starting template. This is because of an issue with PSWriteWord (more specifically with DLL it uses) where Heading styles are not available when using the template created directly in Microsoft Word. The issue was reported PSWriteWord #16 but it's a long time till it will be fixed. Until then simply use Data\EmptyDocument.docx and then add your logos, text, whatever you feel like you need in a template.

Thanks for investigating!
It seems that my Word is crashing the file. With the new template I have the same issue.
If I save a Document once with Word 2016 and use it as template, the headers doesn't work anymore.
Which version of Word do you use to modify the template?

2016+ - I use newest Office 365 edition.