|
Sub 插入公章图片()
' word中如何这样批量插入电子印章
' https://club.excelhome.net/thread-1659353-1-1.html
' (出处: ExcelHome技术论坛)
' 2023-12-29终于试成功了。但调整印章的大小还搞不定!!!
'Set fso = CreateObject("scripting.filesystemobject")
'Application.ScreenUpdating = False ' 为了调试观察
Application.DisplayAlerts = False
Set word = CreateObject("word.application")
word.Visible = True
p = ThisWorkbook.Path & "\印章.png"
Set myword = word.documents.Open(ThisWorkbook.Path & "\1.docx")
With word.Selection
.HomeKey unit:=6 ' 光标置于文件首
'.Font.Size = 20 ' 设置字号
.ParagraphFormat.Alignment = 1 ' wdAlignParagraphCenter '''居中显示
If .Find.Execute("印章:") Then ' 查找到指定字符串(印章:)进行替换 。 印章后的 帽号有全角与半角之分,需要注意
.InlineShapes.AddPicture Filename:=p, LinkToFile:=False, SaveWithDocument:=True ' 替换成图片(公章)
End If
End With
word.documents.Close True
word.Application.Quit
Set myword = Nothing
MsgBox "插入完毕!", 64, "提示"
End Sub |
|