請問如何在"BOOK1"檔案巨集執行時,判別此台電腦中"BOOK2"檔案是否也開啟中,
"BOOK2"檔案開啟時→自動關閉"BOOK2"檔案不存檔。
"BOOK2"檔案未開啟時→執行"BOOK1"檔案下一段巨集。
[attach]8773[/attach]作者: wang 時間: 2011-12-13 21:21
Sub xxx()
Dim myFNo As Long
Dim myFileName As String
Dim myErr As Long
myFileName = "c:\BOOK2.xls"
If myFileName = "False" Then Exit Sub
myFNo = FreeFile
On Error Resume Next
Open myFileName For Binary Access Write Lock Write As #myFNo
Close #myFNo
myErr = Err.Number
On Error GoTo 0
If myErr > 0 Then
Workbooks("BOOK2.xls").Close
End If
'...
'...
End Sub作者: loyyee 時間: 2011-12-13 22:10