|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位大神好,偶然看到这个非常实用的网站后发现这里的高手特别多。同时参考其他人的帖子后也解决了很多办公问题。本人现在遇到的问题如下:1.邮件合并时,复制了下面代码后,一旦在页脚也插入域,就会出现移位或者是直接显示域名:
Sub myMailMerge()
Dim myMerge As MailMerge, i As Integer, myname As String
Application.ScreenUpdating = False
Set myMerge = ActiveDocument.MailMerge
With myMerge.DataSource
If .Parent.State = wdMainAndDataSource Then
.ActiveRecord = wdFirstRecord
For i = 1 To .RecordCount
.FirstRecord = i
.LastRecord = i
.Parent.Destination = wdSendToNewDocument
myname = .DataFields(1).Value &"-"& .DataFields(3).Value
.ActiveRecord = wdNextRecord
.Parent.Execute
With ActiveDocument
.Content.Characters.Last.Previous.Delete
.SaveAs "F:\doc\" & myname & ".doc"
.Close
End With
Next
End If
End With
Application.ScreenUpdating = True
End Sub
2.希望有大神能将这段代码改进下,能直接保存为PDF,因为每天有几千份文件输出到印刷厂打印,印刷厂只接收PDF文档,同时为防止装订出错,页脚一定要插入编号和姓名。
|
|