|
'ThisWorkbookModule
Option Explicit
Private bk_close As Boolean
Private WithEvents xlApp As Application '●
'-----------------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
bk_close = True
Me.Windows(1).WindowState = xlMaximized '●
Set xlApp = Nothing '●
End Sub
'-----------------------------------------------------------
Private Sub Workbook_Open()
Set xlApp = Application '●
test1
End Sub
'-----------------------------------------------------------
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
'(省略)
End Sub
'-----------------------------------------------------------
Sub wnChk()
'(省略)
End Sub
'-----------------------------------------------------------
Sub test1()
'(省略)
End Sub
'-----------------------------------------------------------
Private Sub xlapp_WindowActivate(ByVal Wb As Workbook, _
ByVal Wn As Window) '●
Dim w As Window
If Wb Is Me Then
Wn.WindowState = xlNormal
xlApp.EnableEvents = False
For Each w In Wb.Windows
w.Activate
Next
Wn.Activate
xlApp.EnableEvents = True
Else
Wn.WindowState = xlMaximized
End If
End Sub
'●が追加です。
あと、『サブ』を閉じた時、test1で『メイン』と『サブ』が入れ替わっちゃいますけど、
それで不都合あるならCaptionで判断して分岐処理するなど、工夫してみてください。
|
|