Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Template - Table of Content/Headding failed #12

Open
ferwe opened this issue Dec 19, 2018 · 9 comments
Open

Custom Template - Table of Content/Headding failed #12

ferwe opened this issue Dec 19, 2018 · 9 comments
Labels
bug in external module Bug in external module that we have no control of bug Something isn't working workaround Workaround for an issue provided

Comments

@ferwe
Copy link
Contributor

ferwe commented Dec 19, 2018

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

@PrzemyslawKlys
Copy link
Member

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.

@PrzemyslawKlys PrzemyslawKlys added the bug Something isn't working label Dec 19, 2018
@ferwe
Copy link
Contributor Author

ferwe commented Dec 19, 2018

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.

@ferwe
Copy link
Contributor Author

ferwe commented Dec 19, 2018

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

@PrzemyslawKlys
Copy link
Member

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

@ferwe
Copy link
Contributor Author

ferwe commented Dec 19, 2018

Same result. Already tested :)

@PrzemyslawKlys
Copy link
Member

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

@PrzemyslawKlys
Copy link
Member

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.

@PrzemyslawKlys PrzemyslawKlys added bug in external module Bug in external module that we have no control of workaround Workaround for an issue provided labels Dec 23, 2018
@ferwe
Copy link
Contributor Author

ferwe commented Jan 7, 2019

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?

@PrzemyslawKlys
Copy link
Member

2016+ - I use newest Office 365 edition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in external module Bug in external module that we have no control of bug Something isn't working workaround Workaround for an issue provided
Projects
None yet
Development

No branches or pull requests

2 participants