LoginSignup
1
4

More than 5 years have passed since last update.

VBAで自動的にサイトへログインをする

Last updated at Posted at 2018-06-16

前回の方法だと上手くログインまで行けなかったので他の方法で試したら出来ました。

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor",100000,"REG_DWORD"

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True

objIE.FullScreen = False
objIE.Top = 0
objIE.Left = 0
objIE.Width = 1280
objIE.Height = 964

objIE.Toolbar = True
objIE.MenuBar = True
objIE.AddressBar = True
objIE.StatusBar = True

objIE.Navigate2 "ログインしたいサイトのURL"

Do Until objIE.Busy = False
    WScript.sleep(250)
Loop

objIE.Document.Forms(0).Item(2).value = "自分のログインID"
objIE.Document.Forms(0).Item(3).value = "自分のパスワード"
objIE.Document.Forms(0).Submit

Set WSHShell = WScript.CreateObject("WScript.Shell")
WSHShell.AppActivate "Explorer"

サイトの入力部分を指示する下記の部分は、使用するサイトの構成で違ってくる。

objIE.Document.Forms(0).Item(2).value = "自分のログインID"
objIE.Document.Forms(0).Item(3).value = "自分のパスワード"
objIE.Document.Forms(0).Submit

構成の中のidやNameでやっても上手く行かない無い場合は、Fromで指示すると上手くいきました。

===課題===
サイト内で特定の場所を自動的にクリックするにはどうすれば良いのか。

1
4
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
4