|
こんな感じでしょうか?
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim test_bk As Workbook
Dim test_ws As Worksheet
On Error Resume Next
Set test_bk = Workbooks("test.xls")
If test_bk Is Nothing Then
MsgBox "test.xls" & _
"を開いてから実行して下さい。"
Cancel = True
On Error GoTo 0
Exit Sub
End If
Set test_ws = test_bk.Worksheets("Sheet1")
If test_ws Is Nothing Then
MsgBox "test.xlsにSheet1が有りません。"
Cancel = True
On Error GoTo 0
Exit Sub
End If
test_ws.Range("F6").ClearContents
On Error GoTo 0
End Sub
|
|