如何在 MS Word 中的每个标题末尾应用宏?

发布于 2024-08-12 03:22:50 字数 254 浏览 2 评论 0原文

我有一个包含各种标题的文档(因此不一定是标题 1 或标题 2 - 而是所有类型的标题)。

我想做的是编写一个宏,例如删除每个标题末尾的 2 个空格。

例如,我们有

“这是一个标题”,

在标题的末尾,我会这样做:

Selection.Delete Unit:=wdCharacters, Count:=2

我需要将其应用在每个标题的末尾。

有谁知道该怎么做?

I have a document with various headings (so not necessarily Heading 1 or Heading 2 - but all types of headings).

What I'm trying to do is write a macro that will, for example, delete 2 spaces at the end of each heading.

For example, we have

This is a heading

At the end of heading, I will do:

Selection.Delete Unit:=wdCharacters, Count:=2

I need this to be applied at the end of each heading.

Does anyone know how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸 2024-08-19 03:22:50

转到第一个标题:

   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToFirst

转到下一个标题

   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToNext

检查您所在的位置以查看是否已到达最后一个标题:

   x=Selection.Start
   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToNext
   if x = Selection.Start then '... last heading reachd

转到当前标题的末尾(例如,要删除字符:

   Selection.EndKey Unit:=wdLine

Goto first heading:

   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToFirst

Goto next heading

   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToNext

Check where you are to see if you have reached the last heading:

   x=Selection.Start
   Selection.GoTo What:=wdGoToHeading,Which:=wdGoToNext
   if x = Selection.Start then '... last heading reachd

Goto end of current heading (for example, to delete chars:

   Selection.EndKey Unit:=wdLine
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文