|
楼主 |
发表于 2022-12-5 20:16
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
贴一下在word中执行 的VBA代码,请各位老师看一下,如何将这个word的VBA代码转成在excel中执行的代码?
---------------------------------------------
Sub word插入图片电子签名()
Application.Visible = False
Dim fpath As String, fname As String, doc As Document, sc As Range
fpath = ActiveDocument.Path & "\"
fname = Dir(fpath & "\" & "*.doc*")
Do While fname <> " "
Set doc = Documents.Open(fpath & "\" & fname)
With doc
With Selection.Find
.Text = " 班主任签名:"
.Wrap = wdFindContinue
End With
Do While Selection.Find.Execute
Selection.Paste
Set mypic = Selection.InlineShapes.AddPicture(FileName:=ActiveDocument.Path & "\周海滨.jpg", SaveWithDocument:=True)
mypic.Width = CentimetersToPoints(2.5)
mypic.Height = CentimetersToPoints(1.2)
Loop
.Save
.Close
End With
fname = Dir
Loop
Application.Visible = True
End Sub
|
|