问题描述
我想使用VBA代码将DocB'插入DocA:Selection.InsertFile DocB.
I want to insert DocB' into DocA using the VBA code:Selection.InsertFile DocB.
DocA在各个方面都是普通文档.
DocA is a normal document in every regard.
DocB有2个部分.首先是正常"的东西.第二部分(正确标记为分节符/下一页)具有一组新的左右边距.
DocB has 2 sections. The first is 'normal' stuff. The second section (properly marked with a Section Break/Next Page) has a new set of left and right margins.
使用上述VBA命令将DocB插入DocA时,除DocB第二部分的边距不会带入DocA之外,所有格式设置(字体,间距等)均不适用. (分节符/新页标记仍然存在,并且在已汇编"文档中可见.)
When DocB is inserted into DocA with the above VBA command, all formatting (fonts, spacing, etc.) EXCEPT that the margins in the second section of DocB don't carry into DocA. (The Section Break/New Page marker is still present and visible in the 'assembled' document.)
为什么用Selection.InsertFile命令删除/忽略了我的页边空白?
Why are my margins being erased/ignored with a Selection.InsertFile command?
(我可以手动将DocB的内容复制并粘贴到DocA中,而不会出现问题.)
(I can manually copy and paste the content of DocB into DocA without issue.)
推荐答案
Word在分节符中存储页边距设置,页眉,页脚和类似的布局信息.对于文档的最后一个部分(如果没有分节符,则为唯一的部分),该信息存储在最后一个段落标记中.
Word stores margin settings, headers, footers and similar layout information in the section breaks. For the last section of a document (or the only section if there are no section breaks) this information is stored "in" the last paragraph mark.
当您复制/粘贴文档时,将包括带有节格式的最后一个段落标记.
When you copy/paste a document, that last paragraph mark with the section formatting is included.
当您使用VBA插入文件时,最后一个段落标记被切除.这就是为什么您失去利润的原因.为了保留该信息,在插入文件之前,需要在文档末尾添加分节符(可能是连续的).顺便说一句,这基本上就是主/子文档功能的功能.
When you use VBA to insert a file, that last paragraph mark is cut off. That's why you're losing the margins. In order to retain that information, before you insert the file you need to add a section break (probably continuous) to the end of the document. This is basically what the Master-/Subdocument functionality does, by the way.
这篇关于vba插入文件时,新节中的边距消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!