Quantcast
Channel: OKWAVE 最新質問(Visual Basic/257)【本日】
Viewing all articles
Browse latest Browse all 6510

vbaでnanacoにログイン(ie操作)

$
0
0
私は「緑のパスワードがなくnanacoをお持ちの方」です。 カード記載の番号にはvbaで値を入れることはできるのですが、 nanaco番号に値を入れることとログインボタンを押すことができません。 ********************************************** Sub nanaco() Dim objIE As InternetExplorer Dim myObj As Object Set objIE = CreateObject("InternetExplorer.Application") objIE.Visible = True objIE.navigate "https://www.nanaco-net.jp/pc/emServlet" Do While objIE.Busy = True DoEvents Loop Do While objIE.document.readyState <> "complete" DoEvents Loop objIE.document.all("XCID").Value = "12345" objIE.document.all("SECURITY_CD").Value = "Password" For Each myObj In objIE.document.forms(0).all If TypeName(myObj) = "HTMLInputElement" Then If myObj.alt = "ログイン" Then myObj.Click Exit For End If End If Next Set objIE = Nothing End Sub ********************************************** これだとまずall("XCID").Value でエラーになります。 ソースでは、 <input name="XCID" tabIndex="1" class="txtBoxLogin" accessKey="1" type="text" maxLength="16" value=""/> となっておりますが、同じコードが二つあるからエラーになるのでしょうか? all("SECURITY_CD").Value は問題なくできます。 ソースにも、SECURITY_CDは一つしかないです。 次にログインボタンも二つあるのですが、 For Each myObj In objIE.document.forms(0).all If TypeName(myObj) = "HTMLInputElement" Then If myObj.alt = "ログイン" Then myObj.Click Exit For End If End If Next このコードを実行すると、多分上の方のログインボタンが押されてるようです。 なので、 Dim 二つ目 As Boolean For Each myObj In objIE.document.forms(0).all If TypeName(myObj) = "HTMLInputElement" Then If myObj.alt = "ログイン" Then If 二つ目 = True Then myObj.Click Exit For End If 二つ目 = True End If End If Next に変更してみたのですが、 どうやら If myObj.alt = "ログイン" Then になるのは、1回しかないようです。 うーん、うまくできません。 ご教授よろしくお願いします。

Viewing all articles
Browse latest Browse all 6510

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>