In the past two days, the customer needs to pass the application information in the databaseWordPrint it out, so we export the database recordsExcelIn the file, the customer makes it by themselvesWordTemplate document, and then print it using the Mail Merge functionExcelBut encountered a problem when processing the photo.
ExcelThe file stores the image file path of the applicant,WordWhen printing, You need to print the actual image (2000(Left and right), it is not advisable to insert images one by one, so I want to continue to use the insert domain method for processing:
Theoretically, it should be possible. In actual use, we find that the first image is always displayed, and you need to manually PressF9To refresh the image. If you use "merge to New Document", you cannot refresh the image. This is indeed a headache.
After a long time, I made a macro:
Sub Preview ()
'
'Preview macro
'Macro was recorded by XXX in
'
Dim data as mailmergedatasource
Set Data = activedocument. mailmerge. datasource
Data. activerecord = wdfirstdatasourcerecord
Selection. Fields. Update
For I = 1 to data. recordcount
Activedocument. printpreview
Msgbox ("no." + STR (I) + "records are printed. ")
'Activedocument. Printout
Data. activerecord = wdnextrecord
Selection. Fields. Update
Next
End sub
Haha, stupid. First, locate the first record, refresh the image (when opening the document, select the image domain first), print it, and move it to the next record, until all records are printed.
Although the problem is solved in this way, it is always uncomfortable and cannot be merged into new documents. It is always inconvenient to print a few or more documents. Think about it. If the template document just inserts the includepictur domainCodeInstead of the actual image, it is more appropriate to insert the actual image in the merged document.
InOffice onlineSearch for domain information on the website and findSetYou can set tags for the domain, so you can process them as follows:
The merged document contains the following content:
Switch to the domain result view (CTRL + F9), And then select all (CTRL +), And then pressF9Update domain, everythingOK.