Word insert file VBA merge File

Source: Internet
Author: User

(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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.