特殊・他 ブラウザ上のインプットボックス入力とボタンクリック操作

※より実装に近く表示させる為、コードの改行を避けています。スマホ等で閲覧される際は向きを変えてご覧ください。

※実装するバージョンによってはバージョンアップの仕様により動作しないコードもあります。実装には動作確認の上ご使用下さい。

Option Explicit


Private Sub CommandButton1_Click()
'*********************************************************
'ブラウザ上のインプットボックス入力とボタンクリック操作
'*********************************************************
'UserForm1にWebBrowser1を設置
'UserForm1にCommandButton1を設置

Dim IE As Object, NvgtURL As String, InptTxt(2) As String
Dim InptPss As String

NvgtURL = "http://abc.ne.jp"    '該当ページURL
InptTxt(1) = "abc"              'ID等
InptTxt(2) = "def"              'ID等
InptPss = "ghij"                'PASS等

Set IE = Me.WebBrowser1

IE.Navigate NvgtURL             '該当ページ表示

IE.Visible = True

Do While IE.Busy                '表示まで待機
    DoEvents
Loop

'【例ページソース】
'<form name="GETABC">
'            ~~~~~~
'<input type="text" name="IDno1">
'                         ~~~~~
'<input type="text" name="IDno2">
'                         ~~~~~
'<input type="password" name="PWno1">
'                             ~~~~~
'<input type="submit" name="LOin">
'                           ~~~~
'</form>

IE.Document.GETABC.IDno1.Value = InptTxt(1) 'テキスト入力
'           ^^^^^^ ^^^^^
IE.Document.GETABC.IDno2.Value = InptTxt(1) 'テキスト入力
'           ^^^^^^ ^^^^^
IE.Document.GETABC.PWno1.Value = InptPss    'テキスト入力
'           ^^^^^^ ^^^^^
IE.Document.GETABC.LOin.Click               'ボタンクリック
'           ^^^^^^ ^^^^^
Do While IE.Busy                '表示まで待機
    DoEvents
Loop

Set IE = Nothing

End Sub

 

 

 

2000年01月01日|[VBサンプルコード]:[特殊・他]