Application.DisplayAlerts = False
If Workbooks.Count = 1 Then
Application.Quit
Else
ThisWorkbook.Close 0
End If
Application.DisplayAlerts = True
Exit Sub
999:
If Info2 <> "" Then MsgBox Info2
Dim Str, GetValue '第3個VBA
On Error Resume Next
Str = "'" & "C:\Users\Desktop\[TEST.xls]TEST'!R1C1" '路徑檔名自行修改
GetValue = Application.ExecuteExcel4Macro(Str)
If Sheet4.[A1] <> GetValue Then MsgBox "WORD!", 48
Dim MyB As Workbook, xB As Workbook, xFile$ '第4個VBA
Set MyB = ThisWorkbook
xFile = "C:\Users\Desktop\TEST1.xls" '路徑檔名自行修改
Application.ScreenUpdating = False
Set xB = Workbooks.Open(xFile, ReadOnly:=True)
xB.Sheets("TEST1").Protect "123"
With MyB.Sheets("TEST2")
.Unprotect "123"
xB.Sheets("TEST3").[B1:BA500].Copy .[B1]
.Protect "123"
End With
回復 3#RCRG
你試試把那行:
On Error Resume Next
改成:
On Error Goto 0
跑跑看是否會有錯誤發生? 若有則看看發生在哪一行? 看看是否能排除問題點.
因為 Resume Next 指令直接忽略錯誤, 而會動到Excel外部的指令(如 : Open 檔案), 用這個指令有可能會出現無法預期的結果.