Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created May 30, 2014
Embed
What would you like to do?
ドロップダウンリスト開く
Option Explicit
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Private Declare PtrSafe _
Function IUnknown_QueryService Lib "shlwapi.dll" ( _
ByVal punk As IUnknown, _
guidService As GUID, _
riid As GUID, _
ppvOut As IAccessible _
) As Long
Sub hoge()
Dim IID_IAccessible As GUID
With IID_IAccessible
.Data1 = &H618736E0
.Data2 = &H3C3D
.Data3 = &H11CF
.Data4(0) = &H81
.Data4(1) = &HC
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H38
.Data4(6) = &H9B
.Data4(7) = &H71
End With
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "http://www.7key.jp/hp/_form/6.html"
While ie.busy Or ie.ReadyState <> 4
DoEvents
Wend
'ComboBoxの参照をセット
Dim cmb As MSHTML.IHTMLSelectElement
Set cmb = ie.document.all("kamoku2")
'目的のComboBoxかどうかの確認
'cmb.selectedIndex = 1
Dim hr As Long
Dim pElement As MSHTML.IHTMLElement
Set pElement = cmb
'IHTMLElementからIAccessibleを取り出す
Dim acc As IAccessible
hr = IUnknown_QueryService(pElement, IID_IAccessible, IID_IAccessible, acc)
'Debug.Print acc Is Nothing, Hex(hr)
If hr < 0 Then Exit Sub
'Debug.Print acc.accChildCount
'ドロップダウンリスト開く
acc.accDoDefaultAction 2&
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment