質問編集履歴
1
(1)社内サイトからダウンロードしたExcelファイルを開く コードを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
以下、(1)社内サイトから
|
1
|
+
以下、(1)社内サイトからダウンロードしたExcelファイルを開く、(2)開いたエクセルファイルを取得するコードです(動作はOK)。
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -52,13 +52,59 @@
|
|
52
52
|
|
53
53
|
・
|
54
54
|
|
55
|
-
'(1)社内サイトから自動でExcelファイルを開く
|
56
|
-
|
57
55
|
(省略)
|
58
56
|
|
59
57
|
・
|
60
58
|
|
61
59
|
・
|
60
|
+
|
61
|
+
'(1)社内サイトからダウンロードしたExcelファイルを開く
|
62
|
+
|
63
|
+
Dim o As IUIAutomation
|
64
|
+
|
65
|
+
Dim e As IUIAutomationElement
|
66
|
+
|
67
|
+
Set o = New CUIAutomation
|
68
|
+
|
69
|
+
Dim h As LongPtr
|
70
|
+
|
71
|
+
h = ie.hwnd
|
72
|
+
|
73
|
+
h = FindWindowEx(h, 0, "Frame Notification Bar", vbNullString)
|
74
|
+
|
75
|
+
If h = 0 Then Exit Sub
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
Set e = o.ElementFromHandle(ByVal h)
|
80
|
+
|
81
|
+
Dim iCnd As IUIAutomationCondition
|
82
|
+
|
83
|
+
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "ファイルを開く")
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
Dim Button As IUIAutomationElement
|
88
|
+
|
89
|
+
Dim InvokePattern As IUIAutomationInvokePattern
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
While InvokePattern Is Nothing
|
94
|
+
|
95
|
+
DoEvents
|
96
|
+
|
97
|
+
Set Button = e.FindFirst(TreeScope_Subtree, iCnd)
|
98
|
+
|
99
|
+
Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId)
|
100
|
+
|
101
|
+
Wend
|
102
|
+
|
103
|
+
InvokePattern.Invoke '『開く』ボタンを押すコード
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
62
108
|
|
63
109
|
'(2)自動で開かれたワークブックオブジェクトを取得する
|
64
110
|
|
@@ -94,7 +140,7 @@
|
|
94
140
|
|
95
141
|
Else
|
96
142
|
|
97
|
-
DoEvents
|
143
|
+
DoEvents (★)
|
98
144
|
|
99
145
|
Sleep 100
|
100
146
|
|