在插入构建块之前定位光标,同时避免之后分页
我有一个全页的 Building Block,通过 Building Blocks Organizer 保存为名称:“aWaiver”,在我的自定义类别中:“Quick Parts”库中的“Waivers”,其中 Building Block 属性:“在其自己的页面上插入内容”。
两个问题: (1) 我似乎无法找到正确的“Selected.Range”VBA 代码来用于定位到我想要插入 aWaiver 构建块的当前(最后或唯一)页面的底部。 (2) 当我手动找到文档底部并插入 aWaiver 时,它确实开始了自己的页面,但随后插入了另一个空白页。
这是我根据录制的宏修改的 vba 代码,尽管存在上述问题,但它似乎可以工作。
"C:\Users\Brian\AppData\Roaming\Microsoft\Templates\Normal.dotm"). _
BuildingBlockEntries("aWaiver").Insert Where:=Selection.Range, _
RichText:=True```
I have a full-page Building Block I saved through the Building Blocks Organizer as name: "aWaiver" in my custom category: "Waivers" in the "Quick Parts" Gallery with Building Block Property: "insert content on its own page".
Two issues:
(1) I cannot seem to discover the proper "Selected.Range" VBA code to use to locate to the bottom of the current (last or only) page where I want to insert my aWaiver building block.
(2) When I manually locate to the bottom of my document and insert the aWaiver, it does begin its own page, but then inserts another following blank page.
Here is vba code I modified from the macro I recorded that seems to work albeit with the above issues.
"C:\Users\Brian\AppData\Roaming\Microsoft\Templates\Normal.dotm"). _
BuildingBlockEntries("aWaiver").Insert Where:=Selection.Range, _
RichText:=True```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Selection
对象仅在不可避免的极少数情况下使用。要在文档末尾添加您的 Building Block,您可以使用Where:=Document.Characters.Last
Selection
object is only used in exceptionally rare circumstances when it is unavoidable. To add your Building Block at the end of the document you can useWhere:=Document.Characters.Last
鉴于我获得单词读写能力的建议,我不愿意发帖。但这篇文章确实出现在谷歌搜索中各种关键词的结果中。因此,我将分享我的解决方案,因为我知道它缺乏最佳实践。
在原型文档最后一段的末尾,我添加了一个
bkPageBreakHere
书签。然后,我将快速零件库中的选择另存为新类别Waivers
为aPartialWaiver
,并带有选项仅插入内容
(结果是将内容作为其自己的页面插入
在之后而不是之前进行分页)转向 VBA 代码,我发现 Building Blocks 不会自动随我的模块一起加载。因此,我在文档中输入:
最后,在我的表格中:
问题仍然存在。 (1) 尽管如此,我在最后一个合法页面之后仍然得到一个空白页面。 (不,我不会在最后一页上执行上述代码部分。) (2) 从模板调用文档时,我收到“安全警告宏已被禁用”。
但总而言之,客户很满意。我将继续我的努力寻找解决方案。欢迎任何想法,但不是预期的。
I’m reluctant to post given the recommendation that I gain Word literacy. But this post does appear in results for various key words in a Google Search. So, I will share my solution knowing that it lacks best practices.
At the end of my last paragraph in my prototype document I added a
bkPageBreakHere
bookmark. I then saved the selection in the Quick Parts gallery as a new CategoryWaivers
asaPartialWaiver
with Optioninsert content only
(turns out thatinsert content as its own page
does the page break after, not before)Turning to the VBA Code, I found that Building Blocks did not automatically load with my module. So into the document I entered:
Finally, in my form:
Issues remain. (1) Despite everything, I still get an empty page after my last legitimate one. (No, I do NOT execute the above code section on my last page.) (2) I get the “Security warning Macros have been disabled” when invoking the document from a template.
But all in all, the client is satisfied. I’ll continue my flailing to find a solution. Any thoughts welcome but not expected.