(1) In word, multiple files need to be merged. Word itself provides a very simple method. You only need to use the "insert-> file" command to complete this operation.
VBACode: Selection. range. insertfile (afilename, '', false );
(2) However, there may be some problems to insert the file, so the header information is not lost.
For example, some pages of the file I inserted are horizontal, but after the file is inserted.
In fact, it is very easy to solve this problem, that is, when you insert a file, select "Link" to insert, as shown in figure
VBA code: selection. range. insertfile (afilename, '', false, true, false );
(3) A new problem arises. The file inserted by the link has a gray background, which is ugly. What should we do?
In general, word will display the selected domain with a gray background (the gray background will not be printed during printing), mainly because the "Domain shading" option plays a role. If you do not want to use this display method, you can run the "options" command in the "tool" menu, on the "View" tab, select the "do not show" option in the "Domain shading" box to cancel display.
VBA code: activewindow. View. fieldshading: = wdfieldshadingnever;
(4) because the link insertion method indirectly uses the word file domain "includetext", this may cause the "Domain nesting too deep" error. In fact, the solution is also very simple, that is, disconnecting is equivalent to reducing a domain. So it won't "Domain Nesting is too deep" ^_^. The specific operation is as follows: in the menu "edit-> link", open the link source.
VBA code: activedocument. Fields. Item (1). linkformat. breaklink;