-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathThisAddIn.vb
55 lines (42 loc) · 1.92 KB
/
ThisAddIn.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Imports System.Diagnostics
Imports System.Windows.Forms
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Excel
Public Class ThisAddIn
Private taskPanes As Dictionary(Of Integer, taskPane)
Private Sub ThisAddIn_Startup() Handles Me.Startup
taskPanes = New Dictionary(Of Integer, taskPane)
' 1つのインスタンスにしようとすると、複数のWindowを開いた場合、次のエラーとなる。
' 「基になる RCW から分割された COM オブジェクトを使うことはできません。」
' taskPaneSingle = New TaskPaneControl()
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
Private Sub Application_WindowActivate(Wb As Workbook, Wn As Window) Handles Application.WindowActivate
ChangeTaskPaneVisible(Wn)
End Sub
Public Sub ChangeTaskPaneVisible(Wn As Window)
If taskPanes.ContainsKey(Wn.Hwnd) = False Then
taskPanes(Wn.Hwnd) = New taskPane With {
.Pane = Me.CustomTaskPanes.Add(New TaskPaneControl(), "テキスト編集", Wn)
}
End If
taskPanes(Wn.Hwnd).Pane.Visible = Globals.Ribbons.ManageTaskPaneRibbon.TextEditPaneShow.Checked
End Sub
Private Class taskPane
Private WithEvents taskPaneValue As Microsoft.Office.Tools.CustomTaskPane
Private Sub taskPaneValue_VisibleChanged(sender As Object, e As EventArgs) Handles taskPaneValue.VisibleChanged
If taskPaneValue.Visible = False Then
Globals.Ribbons.ManageTaskPaneRibbon.TextEditPaneShow.Checked = False
End If
End Sub
Public Property Pane As Microsoft.Office.Tools.CustomTaskPane
Get
Return taskPaneValue
End Get
Set(value As Microsoft.Office.Tools.CustomTaskPane)
taskPaneValue = value
End Set
End Property
End Class
End Class