|
↓
「検索ダイアログに入力されている文字列の取得」の
場合なら、以下のような方法でいいと思います。
(サンプル) * 環境がないので、Excel2007ではテストしていません。
Declare Function FindWindowExA Lib "User32" _
(ByVal h1 As Long, ByVal h2 As Long, _
ByVal sz1 As String, ByVal sz2 As String) As Long
Declare Function GetWindowTextA Lib "User32" _
(ByVal Hwnd As Long, _
ByVal lpString As String, _
ByVal nMaxCount As Long) As Long
Declare Function SendMessageA Lib "User32" _
(ByVal Hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Const WM_CLOSE& = 16
Sub Test()
Dim buf As String
Dim hDlg&, h&, i&
Const n$ = vbNullString
buf = String$(30, vbNullChar)
CommandBars.FindControl(, 1849).Execute
hDlg = FindWindowExA(0, 0, n, "検索と置換")
h = FindWindowExA(hDlg, 0, n, n)
i = GetWindowTextA(h, buf, 30)
SendMessageA hDlg, WM_CLOSE, 0, 0
MsgBox Left$(buf, i)
End Sub
|
|