|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
批量替换同目录下所有工作簿内的指定内容,为什么报“424错误,要求对象”错误?请指点,谢谢。
Sub Test()
Dim myPath$, myName$, AK As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
myPath = ThisWorkbook.Path
myName = Dir(myPath & "\" & "*.et")
Do While myName <> ""
If myName <> ThisWorkbook.Name Then
Set AK = Workbooks.Open(myPath & "\" & myName)
End If
Cells.Replace What:="abc", Replacement:="efg"
AK.Save
AK.Close
myName = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|
|