LoginSignup
1
2

More than 5 years have passed since last update.

ExcelVBA IE操作サンプル

Posted at

概要

 ExcelVBAを利用した、IE操作用のサンプル。
 セルの値をIE側へ転記したい時などに利用。

VBAサンプル

表示済みのIEを捕まえる
    Dim ie As Object    'IEを格納する変数(オブジェクト型)
    Dim sh As Object    '起動中のShellWindow一式を格納する変数
    Dim win As Object   'ShellWindowを格納する変数
    Dim document_title As String  'ドキュメントタイトルの一時格納変数
    '起動中のShellWindow一式を変数winsに格納
    Set sh = CreateObject("Shell.Application")
    'ShellWindowから1つずつ取得して処理
    For Each win In sh.windows
        'ドキュメントタイトル取得失敗を無視(処理継続)
        On Error Resume Next
        document_title = ""
        document_title = win.Document.Title
        On Error GoTo 0
        'タイトルバーに"取得したいタイトル"が含まれるかチェック
        If InStr(document_title, "取得したいタイトル") > 0 Then
            '変数ieに取得したwinを格納
            Set ie = win
            'ループを抜ける
            Exit For
        End If
    Next
Excel内のセル値を、IE側へ転記する
 ie.Document.getElementsByName(InStrStartH)(0).Value = 変数
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2