|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 替换()
Application.ScreenUpdating = False
Dim i%, arr, myPath$, wdApp, wdD
myPath = ThisWorkbook.Path & "\"
Set wdApp = CreateObject("word.application")
wdApp.Visible = False
F = Dir(myPath & "*.doc*")
Do While F <> ""
mc = Split(F, ".")(0)
Set wdD = wdApp.Documents.Open(myPath & F)
wdD.Tables(1).cell(1, 2).Range.Text = mc
wdD.Close True
F = Dir
Loop
wdApp.Quit
Set wdD = Nothing
Set wdApp = Nothing
Application.ScreenUpdating = False
MsgBox "ok!"
End Sub
|
|