跳到主要内容

更新 Word 文档中的目录 Power Automate

PDF4me 更新目录 是一个 Power Automate 此操作可扫描 Word 文档的标题,并自动生成或刷新其目录。无需打开 Word,即可在文档进入工作流程后立即为其添加专业、可点击的导航,适用于技术手册、学术论文或长篇报告。

此操作的作用

PDF4me 更新目录 读取 Word 文档中配置范围内的标题 1 到标题 6 样式,然后更新现有的目录字段或在文档开头创建一个新的目录字段,并可控制超链接、制表符前导符、字母大小写和区域设置。

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

要访问 PDF4me 网站 API 通过 Power Automate每个请求都必须包含一个有效的 API 关键在于身份验证,它可以验证您的身份,并使连接器能够从您的流程访问 PDF4me 的 Word TOC 服务。

您不容错过的重要事实

更新现有目录或创建新目录。
该操作首先扫描是否存在目录字段。如果不存在,则会在文档开头插入一个标题为“目录”的新字段。
三个字段被归类为高级参数
“隐藏制表符前导符”、“使用大写字母”和“区域名称”位于连接器的“高级参数”切换开关后面,而不是在主窗体上。
标题级别支持范围和多个范围
使用“1-3”表示范围,“1”表示单个级别,或者使用“1-2,4-6”将不相邻的范围合并到一个目录中。
Power Automate PDF4me Word 更新目录操作显示文件内容、文件名、标题级别、使用超链接和高级参数面板

“文件内容”、“文件名”、“标题级别”和“使用超链接”位于主表单上;“隐藏制表符前导符”、“使用大写字母”和“区域名称”是高级参数。

参数

必需的: 文件内容和文件名必须始终提供。标题级别和使用超链接具有默认设置,“隐藏制表符前导符”、“使用大写字母”和“区域名称”是可选的高级参数。

范围必需的它的作用例子
File ContentRequiredBase64 content of the source Word file, typically mapped from a prior action like SharePoint or OneDrive Get File Content. Must be a valid .docx or .doc document.[File Content from Get File]
File NameRequiredName of the Word file including its extension, used for processing and output naming; the output filename matches the input.document.docx
Heading LevelsOptionalRange of Word heading styles to include, for example "1-3" for levels 1 through 3, "1" for a single level, or "1-2,4-6" for combined ranges. Defaults to "1-3".1-3
Use HyperlinksOptionalYes makes TOC entries clickable links to their headings; No renders plain text entries. Defaults to Yes.Yes
Hide Tab LeaderOptionalAdvanced parameter. Yes removes the dotted line between entry text and page numbers; No keeps it. Defaults to Yes.Yes
Use UppercaseOptionalAdvanced parameter. Yes renders all TOC entries in uppercase; No preserves the heading's original case. Defaults to Yes.Yes
Culture NameOptionalAdvanced parameter. Locale code such as en-US or de-DE for document processing and metadata; leave blank for no culture-specific handling.en-US

更新目录会返回什么?

场地类型它包含什么
documentBase64Word document with the Table of Contents updated or newly created.
SuccessBooleantrue when the update completed, false if the request failed validation or processing.
Error MessageStringDescription of what went wrong, null when Success is true.
ErrorsArrayDetailed error entries, empty when Success is true.
{
"document": "[Base64 Word Content with Updated Table of Contents]",
"Success": true,
"ErrorMessage": null,
"Errors": []
}

常见错误信息

错误信息原因解决方案
Request is emptyRequest object is null.Provide a valid request object.
Document is emptyDocument object is null.Provide a valid Word document.
Error loading document from bytesInvalid or corrupted Word document.Verify the input document is a valid Word file (.docx).
No headings found in documentDocument has no heading styles applied.Apply Heading 1 through Heading 6 styles to the sections that should appear in the TOC.
Invalid heading levels specifiedHeading Levels contains an invalid format.Use a valid format such as "1-3", "1", or "1-2,4-6".
Invalid culture name providedCulture Name is not a recognized locale.Use a valid culture code such as en-US or fr-FR.

如何在设置中更新目录 Power Automate

  1. 添加 PDF4me更新目录 致你 Power Automate 流动。
  2. 地图 文件内容文件名 源自之前的操作,例如 SharePoint 或者 OneDrive 获取文件内容。
  3. 标题级别 包含的标题样式范围,以及 使用超链接 控制条目是否可点击。
  4. 打开 高级参数 如果文档需要非默认的制表符前导符、字母大小写或其他特定格式 文化名称 当地的。
  5. 运行流程。 PDF4me 更新或创建目录,并将 Word 文档返回。 document

我应该使用哪个标题级别范围?

使用 1-3这是大多数商业文档和报告的默认设置,因为它能捕获章节和子章节标题,而不会包含更小的子子标题。使用 更宽的范围,例如“1-6” 适用于需要可浏览的复杂法律或技术文档,尤其是那些嵌套层级较深的文档。使用 组合范围,例如“1-2,4-6” 当文档的 3 级标题是装饰性的或重复的,应该跳过,但仍然要保留其下方的更深层次的结构时。

典型配置

工作流程示例Common Power Automate flow patterns using Update Table of Contents.
自动技术手册索引
  1. 当技术手册上传到某个平台时,就会触发一个流程。 SharePoint “手册”库。
  2. 获取文件功能检索已上传的 Word 文档。
  3. 更新目录时,标题级别设置为“1-4”,使用超链接设置为“是”。
  4. 索引手册已保存回图书馆,读者可以随时在各章节之间跳转。
学术论文格式标准
  1. 研究论文提交流程收到一份新的稿件。
  2. 更新目录时,标题级别设置为“1-3”,隐藏制表符前导符为“是”,使用大写字母为“是”,以符合部门的格式标准。
  3. 标准化试卷将送交评审委员会进行评估。
本地化文档分发
  1. 国际文件流为区域办事处准备了一份翻译后的 Word 文件。
  2. 更新目录时,会将“区域名称”设置为目标区域,例如“de-DE”,以及标准的“标题级别”和“使用超链接”设置。
  3. 本地化、可浏览的文档已分发给区域团队。

实用技巧

Apply real Word heading styles before running the action
The TOC is built from Word's Heading 1 through Heading 6 styles, not from bold text or larger font sizes. A document with no styled headings returns a "no headings found" error.
Open Advanced parameters to reach three of the seven fields
Hide Tab Leader, Use Uppercase, and Culture Name are not on the connector's main form. Expand Advanced parameters in the designer to set them.
Test the Heading Levels format on one document first
A malformed range like "1,3" instead of "1-3" or "1,3-4" returns an invalid heading levels error. Confirm the format on a sample file before wiring it into a production flow.
Re-run on documents with an existing TOC to refresh page numbers
The action detects and updates an existing TOC field rather than duplicating one, so it is safe to re-run after content changes shift page numbers.
Match Culture Name to the document's actual language
An unrecognized or mismatched culture code returns an invalid culture name error; use standard codes like en-US or fr-FR rather than a free-text language name.

速查表

场地价值
ActionUpdate Table of Contents
File Content / File NameMapped from a prior action, .docx or .doc
Heading Levels"1-3" default, or "1", or "1-2,4-6"
Use HyperlinksYes (default) or No
Advanced: Hide Tab LeaderYes (default) or No
Advanced: Use UppercaseYes (default) or No
Advanced: Culture Namee.g. en-US, de-DE, blank for none
No headings foundApply Word Heading 1-6 styles first
Outputdocument (Base64 Word), Success, Error Message, Errors

常见问题

How do I automatically generate a Table of Contents in Word with Power Automate?+
Add the PDF4me Update Table of Contents action, map File Content and File Name from a prior action, then set Heading Levels to the range of heading styles to include, for example 1-3. The action scans the document's headings, updates an existing TOC field or creates a new one, and returns the updated Word file.
What happens if the document does not already have a Table of Contents?+
The action creates a new Table of Contents at the start of the document, adding a "Table of Contents" title in the Heading1 style, built from the headings that fall within the configured Heading Levels range.
Which Word heading styles does the Table of Contents pick up?+
The action reads Word's built-in Heading 1 through Heading 6 styles. Heading Levels controls which of those levels are included, using a range like 1-3, a single level like 1, or multiple ranges like 1-2,4-6.
Can I control hyperlinks, tab leaders, and letter case in the generated TOC?+
Yes. Use Hyperlinks makes TOC entries clickable links to their headings. The Advanced parameters Hide Tab Leader control the dotted line between entry text and page numbers, and Use Uppercase controls whether entries render in uppercase or their original case.
What is the Culture Name parameter for?+
Culture Name sets a locale such as en-US or de-DE for document processing and metadata, useful when generating a Table of Contents for a localized or multi-language document. See <a href="https://learn.microsoft.com/en-us/globalization/locale/locale-names" target="_blank" rel="noopener noreferrer">Microsoft's locale name reference</a> for valid culture codes.
Is there a similar action for headers and footers instead of a TOC?+
Yes, see the PDF4me Update Headers Footers action linked under Related Actions below. See <a href="https://learn.microsoft.com/en-us/connectors/pdf4meconnect/" target="_blank" rel="noopener noreferrer">the PDF4me Power Automate connector reference</a> for the full action list.

行业应用案例及应用

法律行业应用案例

  • 合同导航为复杂的多章节合同生成详细的目录
  • 法律简报为冗长的法庭文件创建易于浏览的结构
  • 合规手册指数监管要求和程序
  • 案例文件整理证据摘要和法律论证

相关操作

在其他平台上执行相同任务

获取帮助