|
UO3様
ちょっと、無理ありそうですけど・・・。
'〜〜〜〜〜〜標準モジュールに〜〜〜〜〜〜〜〜
Public USERFORM_VISIBLE_FLAG As Boolean
'〜〜〜〜〜〜Userformモジュールに〜〜〜〜〜〜
Private Sub UserForm_Activate()
With UserForm1
If USERFORM_VISIBLE_FLAG = True Then
If Application.Top < -100 Then
ElseIf Application.Top >= -100 Then
.Show (vbModeless)
End If
ElseIf USERFORM_VISIBLE_FLAG = False Then
.Hide
End If
End With
End Sub
Private Sub UserForm_Terminate()
USERFORM_VISIBLE_FLAG = Clear
End Sub
'〜〜〜〜〜〜〜ThisWorkbookモジュールに〜〜〜〜〜〜〜〜
Option Explicit
Dim WithEvents xlApp As Application
Private Sub Workbook_Open()
Set xlApp = Application
With UserForm1
.Show (vbModeless)
End With
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Unload UserForm1
End Sub
Private Sub xlApp_WorkbookActivate(ByVal Wb As Workbook)
With UserForm1
.Show (vbModeless)
End With
If Wb Is ThisWorkbook Then USERFORM_VISIBLE_FLAG = True
End Sub
Private Sub xlApp_WorkbookDeactivate(ByVal Wb As Workbook)
With UserForm1
.Hide
End With
If Wb Is ThisWorkbook Then USERFORM_VISIBLE_FLAG = False
End Sub
じゃダメですかね・・・・。
|
|