|
keinさん何度もすいません、有難うございます。
おしゃる通りに書き換えてみたのですがやはりUserForm1.Showで
止まってしまいます。
Private Const fPASSWORD As String = "Passeord" & vbBack
Private Sub HideWindow()
Dim i As Long
For i = Windows.Count To 2 Step -1
Windows(i).Close
Next
Windows(1).Visible = False
Protect fPASSWORD, False, True
End Sub
Private Sub ShowWindow()
Unprotect fPASSWORD
Windows(1).Visible = True
Saved = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Saved Then Exit Sub
Select Case MsgBox("'" & Name & "' への変更を保存しますか?", vbExclamation Or vbYesNoCancel)
Case vbYes
HideWindow
Application.EnableEvents = False
Save
Application.EnableEvents = True
Case vbNo
Saved = True
Case vbCancel
Cancel = True
End Select
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
HideWindow
Application.EnableEvents = False
Save
Application.EnableEvents = True
ShowWindow
Cancel = True
End Sub
Private Sub Workbook_Open()
UserForm1.Show
Application.WindowState = xlMinimized
End Sub
実行時エラー'1004':
'Worksheets'メソッドは失敗しました:'Global'オブジェクトと
言うエラーメッセージが出ます。
|
|