Programmatically using Report Generator to generate a Word report using templates generates an error: "Cannot find template"
조회 수: 16 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2017년 3월 14일
편집: MathWorks Support Team
2023년 5월 4일
I am reading the MATLAB Report Generator documentation, and I am having some trouble understanding the "Automatic Numbering in Word Reports" section:
I copied the code into my MATLAB, but when I try to run it, I get the following error message:
ERROR: Error using mlreportgen.dom.DocumentPart/moveToNextHole
Cannot find template: MyReportTemplate.dotx
Error in Untitled2 (line 17)
moveToNextHole(chapterPart);
I think I need to have a template file called "MyReportTemplate.dotx" in my current path, but I don't know where to find it or how to create it myself.
I have tried all the other examples on this page, but this is the only one that gave me an error.
채택된 답변
MathWorks Support Team
2023년 5월 4일
편집: MathWorks Support Team
2023년 5월 4일
Before you can programmatically create a report using the Report Generator, you need to define a template file. In order to do this, you can use the following command. This creates a new blank template file using "mlreportgen.dom". Make sure that you only use this command once for each template you create, otherwise it will overwrite your existing template of the same name.
Document.createTemplate('MyReportTemplate','docx');
At this point, if you run your code, you might see the following error:
ERROR: Error using mlreportgen.dom.DocumentPart/moveToNextHole
Document does not contain a document part template named: Chapter
Error in Untitled2 (line 17)
moveToNextHole(chapterPart);
This error occurs because the "MyReportTemplate.dotx" template file does not have a document part template with the title "Chapter". You will need to open "MyReportTemplate.dotx" in Microsoft word, and then follow the steps at the documentation link below in order to create the "Chapter" template. Please note that the "Automatic Numbering in Word Reports" example specifies the layout of the "Chapter" template.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Templates에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!