我在网上发现一个旧脚本关闭文档而不保存更改,然后重新打开文档:
Sub RevertFile()
wkname = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
ActiveWorkbook.Close Savechanges:=False
Workbooks.Open Filename:=wkname
End Sub
我想要这个,因为您无法“撤消”因运行宏而导致的更改。但是,它似乎在MS Office v1609中不起作用。首先,文件在关闭后不会重新打开。其次,当我希望它们不被保存时,修改 。如何重写此脚本以使其工作?感谢。
[编辑]
这是我正在使用的另一个子程序。
Sub FixPlatforms()
'PURPOSE: Find & Replace a list of text/values throughout entire workbook
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
Dim sht As Worksheet
Dim platList As Variant
Dim x As Long
platList = Array _
( _
"PS4", "PlayStation 4", _
"PS3", "PlayStation 3", _
"PS2", "PlayStation 2", _
"PSV", "PlayStation Vita", _
"PSP", "PlayStation Portable", _
"WIN", "Microsoft Windows", _
"SNES", "Super Nintendo Entertainment System" _
)
'Loop through each item in Array lists
For x = 1 To UBound(platList) Step 2
'Loop through each worksheet in ActiveWorkbook
For Each sht In ActiveWorkbook.Worksheets
sht.Cells.Replace What:=platList(x), Replacement:=platList(x - 1), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Next sht
Next x
End Sub
它有什么问题吗?
答案 0 :(得分:4)