【发布时间】:2014-03-21 02:05:51
【问题描述】:
我有一个带有 VBA 的宏,但我的程序失败了。 Visual Basic 应用程序向我展示了这个错误:“运行时错误 '438' 对象不支持此属性或方法”
我的代码是:
Sub MACRO()
bAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
For i = 1 To Sheets.Count
***Sheets(i).Cells.Replace What:="C:\", Replacement:="C:\Gestion\"***
Next
Application.DisplayAlerts = bAlerts
End Sub
在 Sheets(i).Cells.Replace What:="C:\", Replacement:="C:\Gestion\" 行中,我的程序不起作用。有什么问题?
我的 excel 文件具有 Microsoft Excel 97-2003 格式。
最后,我可以解决这个问题。
我的新代码是:
Attribute VB_Name = "RemplazoString"
Sub MACRO()
Dim Sht As Worksheet
bAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
For Each Sht In Worksheets
Sht.Cells.Replace What:="C:\", Replacement:="C:\Gestion\", LookAt:=xlPart, MatchCase:=False
Next
Application.DisplayAlerts = bAlerts
End Sub
谢谢!
【问题讨论】:
-
你有
Chart床单吗? -
是的,我发现我的错误!可以!谢谢!