Internet explorer 使用VBA自动化IE登录-出现错误

Internet explorer 使用VBA自动化IE登录-出现错误,internet-explorer,vba,excel,automation,login-script,Internet Explorer,Vba,Excel,Automation,Login Script,已编辑 因此,我对我的脚本进行了更多的修改,并将其复制到当前迭代的下面 我仍然得到同样的错误,但现在它是在一个新的线路。我还添加了下面的源代码,因为链接不是每个人都可以访问的。我在给出错误的代码中加粗了这行 错误是: 对象“IWebBrowser2”的方法“Document”失败 Sub-OpenCIR() 用户名=输入框(“请输入用户名”) 密码=输入框(“请输入密码”) Set objIE=CreateObject(“InternetExplorer.Application”) 网站=”h

已编辑

因此,我对我的脚本进行了更多的修改,并将其复制到当前迭代的下面

我仍然得到同样的错误,但现在它是在一个新的线路。我还添加了下面的源代码,因为链接不是每个人都可以访问的。我在给出错误的代码中加粗了这行

错误是:

对象“IWebBrowser2”的方法“Document”失败


Sub-OpenCIR()
用户名=输入框(“请输入用户名”)
密码=输入框(“请输入密码”)
Set objIE=CreateObject(“InternetExplorer.Application”)
网站=”http://wsmmart.itg.ti.com/"
与奥布杰
.Visible=True
.浏览网站
**请稍候。忙碌或。readyState readyState\u完成**
多芬特
环
出错时继续下一步
Set元素=.document.getElementsById(“fld2”)
元素。项(0)。值=用户名
Set元素=.document.getElementsById(“fld5”)
元素。项(0)。值=密码
请稍候。忙碌或。readyState readyState\u完成
多芬特
环
以
端接头

源代码:

<html>
<head>
   <title>TI-pass Login</title>

       <meta http-equiv="expires"
           content="Mon, 12 Sep 2005 02:59:54 GMT">
   <meta http-equiv="pragma"
           content="no-cache">
   <script language="javascript"
           src="https://ti-pass.ext.ti.com/scripts/iatc.js"
           type="text/javascript"></script>
   <script language="javascript"
           src="https://ti-pass.ext.ti.com/scripts/global.js"
           type="text/javascript"></script>
   <link rel="STYLESHEET" type="text/css" href="https://ti-       pass.ext.ti.com/styles/ticom-portal.css" />
   <link rel="STYLESHEET" type="text/css" href="https://ti-pass.ext.ti.com/styles/ticom-default.css" />
   <link rel="STYLESHEET" type="text/css" href="https://ti-pass.ext.ti.com/styles/genr_style.css"/>

</head>

<body style="text-align: center; margin: 8px;">
<table width="100%" cellspacing="0" border="0" cellpadding="0">
   <tr>
      <td bgcolor="#000000" width="200"><img border="0" width="200"     src="https://myportal.ti.com/loginportal/images/tilogo.gif" alt="Texas Instruments" height="33"></td>
      <td bgcolor="#FF0000" width="100%" align="center" nowrap><span class="navfontwhite" style="font-weight:bold; text-align: center;">Technology&nbsp;For&nbsp;Innovators<sup>TM</sup></span></td>
   </tr>
</table>











<!-- get edit and help -->



<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%" BGCOLOR="#999999">

     <TR>
        <TD COLSPAN=2>
        <table
         bgcolor="white"
         width="100%"
         cellpadding=2
         cellspacing=0
         border=0>
         <tr><td>
    <font color="black" face="Sans-serif">
    <!-- provider content goes here -->












      <script language="javascript"
           src="https://myportal.ti.com/loginportal/scripts/global.js"
           type="text/javascript">
      </script>

      <link rel="STYLESHEET" type="text/css"
           href="https://myportal.ti.com/loginportal/css/genr_style.css">

    <style type="text/css" charset="utf-8">
    .ui-state-error {background:url(https://focus.ti.com/graphics/shared/css/form-error-bg.gif) no-repeat #fff;border:1px solid #B81900;color:#B81900;padding-left:20px;}
   </style>
      <table cellspacing="0" cellpadding="0" width="100%"  border="0">


        <tr>
          <td><span class="pagetitle2">TI-<em>pass</em> Login</td>:</span>&nbsp;<span class="pgsubtitle"></span></td>
        </tr>
        <tr>
          <td><img src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="5" alt="" /></td>
        </tr>
        <tr>
          <td class="divline"><img    src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="1" alt="" /></td>
        </tr>

        <tr>
          <td><img src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="12" alt="" /></td>
        </tr>




        <tr>
          <td valign="top"><p>Welcome to TI's secure log-in site! Enter your User ID and Password:</p></td>
        </tr>

      </table>

<form action="https://ti-pass.ext.ti.com/cgi-bin/login/login.pl"
            method="post" name="userid_form" enctype="application/x-www-form-    urlencoded" onsubmit="return validateLoginForm(this);">

      <table cellspacing="0" cellpadding="0"  border="0">
        <tr>
          <td><input type="image" border="0" name="enter" width="1" height="1" src="https://myportal.ti.com/loginportal/myti_images/s.gif" /></td>
        </tr>
      </table>
      <table cellspacing="0" cellpadding="0" width="80%"  border="0">
         <tr>
           <td colspan="4"><img   src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="15" alt="" border="0" /></td>
         </tr>
         <tr>

          <td valign="top" >

            <table cellspacing="0" cellpadding="0"   border="0">

            </table>


            <table cellspacing="0" cellpadding="0"  border="0">

              <!-- Form Item -->
              <tr>
                <td width="20%" >&nbsp;</td>
                <!-- Prompt -->
                <td class="bodyfontb" align="left"
                    nowrap><strong>User ID</strong></td>
                <!-- Info -->

                <td class="bodyfont" align="center"
                    width="15">&nbsp;</td>
                <!-- Control -->
                <!-- td  -->
                <td class="bodyfont" style="font-size:12px;" align="left"
                    nowrap><input type="text" name="fld2"  value="a0224681" size="20" maxlength="100" tabindex="101" class="frmtxtfld" id="fld2" onblur="validateEmailTIPass(this.id)" /><!-- /span --></td>
                <td width="50%">&nbsp;</td>
              </tr>
              <!-- Form Item -->
              <tr>
                <td width="20%" >&nbsp;</td>
                <!-- Prompt -->
                <td class="bodyfontb" align="left"
                    nowrap><strong>Password</strong></td>
                <!-- Info -->
                <td class="bodyfont" align="center"
                    width="15">&nbsp;</td>
                <!-- Control -->
                <td class="bodyfont" style="font-size:12px;" align="left"
                    nowrap><input type="password" name="fld5"  size="20"  maxlength="12" tabindex="102" class="frmtxtfld" id="fld5" autocomplete="off" /><!-- /span --></td>

                <td width="50%">&nbsp;</td>
              </tr>
              <tr>
              <!-- Form Item -->
                <td width="20%" >&nbsp;</td>
                <td>&nbsp;</td>
                <td class="bodyfont" align="center"
                    width="15">&nbsp;</td>
                <td class="bodyfontb" align="left" valign="top">
                <!-- Prompt -->                <!-- Info -->                <!--     Control -->
                  <input type="image" tabindex="103"
                           src="https://myportal.ti.com/loginportal/myti_images/myti_gl_submit.gif"
                         width="61"
                         height="16" border="0"
                         alt="Submit"
                         name="Submit" /><!-- /span -->
                </td>
                <td width="50%">&nbsp;</td>
              </tr>
                            <!-- Form Item -->
              <tr>
                <td width="20%" >&nbsp;</td>
                <td>&nbsp;</td>
                <td class="bodyfont" align="center"
                    width="15">&nbsp;</td>
                <td class="bodyfont" align="left" valign="top" colspan="2">
                <!-- Prompt -->                <!-- Info -->                <!-- Control -->
                   <input type="checkbox" name="fld3" value="1" CHECKED  tabindex="104" />Remember me |
                      <script type="text/javascript">
                        document.write('<a href=\"javascript:popWin(\'https://ti-pass.ext.ti.com/login/rememberme_pu.html\',\'WhatThis\',\'width=405,height=415\')\" class=\"bodyfont\" style=\"color:#003399; font-size:10px;\">What\'s this?</a><br />');
                       </script>
                   <noscript><a href="https://ti-pass.ext.ti.com/login/rememberme_pu.html" class="bodyfont" style="color:#003399; font-size:10px;" target="_blank">What's this</a><br /></noscript>
                </td>
              </tr>
              <tr>
                <td width="20%" >&nbsp;</td>
                <td colspan=4>
                  <p>
                    To access this site, you must have your browser
                    set to accept temporary cookies. If you need help
                    enabling cookies, please review the following:<br>
                    <a href="https://ti-pass.ext.ti.com/cookie_help.html"
                       target="_blank"
                       onclick="cookie_pop();return false;">How to enable cookies on your browser</a>.
                  </p>
                </td>
              </tr>
              <tr>
                <td>&nbsp;<br /></td>
              </tr>
            </table>

          </td>

          <td width="10"><img   src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="10" height="1" hspace="0" vspace="0" border="0" alt="" /></td>
          <td class="divline" width="1"><img src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="1" hspace="0" vspace="0" border="0" alt="" /></td>
          <td valign="top">
            <table cellspacing="0" cellpadding="0" width="100%"   border="0">
              <tr>
                <td valign="top">

                 <div style="padding-left: 10px;">
                  Forgot your password?<br />                  <div style="padding-top: 5px;">
                  </div>
                  <a href="https://ti-pass.ext.ti.com/cgi-bin/reg/recpwd/recoverpwd1.pl?lt=genr&amp;URI=http://wsmmart.itg.ti.com:80/"><img
                   src="https://myportal.ti.com/loginportal/myti_images/btn_recover_password.gif"
                     width="137"
                     height="16" border="0"
                     alt="Recover Password" /></a>
                  </div>

                </td>
              </tr>
            </table>
          </td>

  </tr>
</table>

<!-- Hidden Parameters -->

                     <input type="hidden" name="xcon_legal_warn" value="1" />

                     <input type="hidden" name="j3" value="1" />

                     <input type="hidden" name="fld1" value="1aU4Mui39Vp" />

                     <input type="hidden" name="portal" value="1" />

                     <input type="hidden" name="j5" value="2" />

                     <input type="hidden" name="OKPage"  value="http://wsmmart.itg.ti.com:80/" />

                     <input type="hidden" name="fld4" value="all" />

                     <input type="hidden" name="ErrPage" value="https://myportal.ti.com:443/portal/dt?j3=1&j5=2&OKPage=http%3A%2F%2Fwsmmart.itg.ti.com%3A80%2F" />

<input type="hidden" name="TI549_token"  value="da08939409d31024ffcefa31351ef4b8b28c02ec" >
<script type="text/javascript" src="https://myportal.ti.com/loginportal/js/shared/myti-validations.js"></script>
  <!-- Set focus of cursor -->
  <script language="javascript">

    document.userid_form.fld5.focus();

</script>

</form>
      <hr>


      <table cellspacing="0" cellpadding="0" width="100%"   border="0">
        <tr>

          <td width="20%" ><img  src="https://myportal.ti.com/loginportal/myti_images/s.gif" width="1" height="15" alt="" border="0" /></td>

          <td>
            <p class="disclaim"><b>NOTICE</b></p>
            <p class="disclaim">
              This is a proprietary system of Texas Instruments Incorporated (TI) or its licensors.
              This system is for the use of authorized users only. Individuals using this system are
              subject to having all of their activities on this system monitored and recorded in order
              to verify that they have appropriate authority and do not use this  system for any
              inappropriate or unlawful purpose. Anyone using this system expressly consents to such
              monitoring. If monitoring reveals unauthorized, inappropriate or possible unlawful activity,
              system personnel will provide information derived from such monitoring to TI management or
              outside legal authorities, as appropriate. Misuse of this system may result in revocation
              or limitation of an individual's access to this system in addition to any other appropriate
              remedies.  Misuse of this system by TI employees may result in disciplinary action,
              including termination.
            </p><tr>
          </td>
        </tr>
      </table>
      <hr>


    </font>
         </td></tr></table>
        </TD>
      </TR>
    </TABLE>

    <img src="/portal/desktop/images/nothing.gif" height="8" width="0" border="0" alt=""><br> 





<!--  











    <TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
      <TR BGCOLOR="#333366">
    <TD VALIGN="MIDDLE" NOWRAP>
      <FONT
        COLOR="#FFFFFF"
        FACE="SANS-SERIF">
        &nbsp;<B>Sun JavaTM System Portal Server 6 2004Q2</B>
      </FONT>
    </TD>
    <TD ALIGN="RIGHT" VALIGN="MIDDLE"  NOWRAP>
      <P ALIGN="RIGHT">
        <FONT COLOR="#FFCC00" FACE="SANS-SERIF" SIZE="+0">
          <A HREF="https://myportal.ti.com/portal/dt" class="noUnderline">
        <FONT COLOR="#FFFFFF" CLASS="nonuw">Home</FONT></A> |
          <A HREF="https://myportal.ti.com/portal/dt? action=edit&provider=WirelessJSPClientConfigContainer" class="noUnderline">
    <FONT COLOR="#FFFFFF" CLASS="nonuw">Mobile Devices</FONT></A> |
          <A HREF="https://myportal.ti.com/portal/docs/en/desktop/usedesk.htm" onClick="javascript: var helpWin=window.open ('https://myportal.ti.com/portal/docs/en/desktop/usedesk.htm', 'wthelp', 'width=600,height=400,hotkeys=no,status=no,resizable=yes,scrollbars=yes,toolbar=yes'); helpWin.focus();return false;" class="noUnderline">
        <FONT COLOR="#FFFFFF" CLASS="nonuw">Help</FONT></A> |
          <A HREF="https://myportal.ti.com/portal/dt?action=logout" onClick="closeWindows(); return true;" class="noUnderline">
        <FONT COLOR="#FFFFFF" CLASS="nonuw">
          <B>Log Out</B>
        </FONT></A>&nbsp;
        </FONT>
      </P>
    </TD>
      </TR>
    </table>

 -->




<table cellpadding="0" cellspacing="10" border="0" width="100%">
   <tr>
    <td width="Right_Side_Width" align="center">
      <table>

        <tr>
          <td width="50%"></td>
          <td align="right"><img height="14" alt="Texas Instruments"
              src="https://myportal.ti.com/loginportal/myti_images/footerlogo.gif" width="117"
              border="0"></td>
          <td class="footerfontcopy" nowrap="nowrap">&nbsp; &copy; <a
              class="footerfontcopy"
              href="http://www.ti.com/corp/docs/copyright.htm">Copyright
              1995-2013</a> Texas Instruments Incorporated. All rights
              reserved.</td>
          <td width="50%"></td>
        </tr>

      </table>
      <span class="footerfonttrade" valign="top" align="center"><a
      class="footerfonttrade"
      href="http://www.ti.com/corp/docs/trademrk.htm">Trademarks</a> | <a
      class="footerfonttrade"
      href="http://www.ti.com/pub/docs/privacy.htm">Privacy Policy</a> |
      <a class="footerfonttrade"
      href="http://www.ti.com/sc/docs/disclaim.htm">Terms of Use</a></span></td>
   </tr>
</table>
</HTML>

TI-pass登录
创新技术TM
.ui状态错误{背景:url(https://focus.ti.com/graphics/shared/css/form-error-bg.gif)无重复#fff;边框:1px实心#B81900;颜色:#B81900;左侧填充:20px;}
TI pass登录:
欢迎来到TI的安全登录站点!输入您的用户ID和密码:

用户ID 密码 记得我吗| 文件。写入(“
”);
若要访问此网站,您必须具有浏览器 设置为接受临时cookie。如果你需要帮助 启用Cookie,请查看以下内容:
.


忘记密码了吗?
document.userid_form.fld5.focus();
通知

这是德州仪器公司(TI)或其许可方的专有系统。 本系统仅供授权用户使用。使用此系统的个人是 按照顺序监控和记录他们在该系统上的所有活动 验证他们是否拥有适当的权限,并且不将此系统用于任何目的 不适当或非法的目的。使用本系统的任何人明确同意 监测。如果监测发现未经授权、不适当或可能的非法活动, 系统人员将向TI管理层或 酌情在法律当局之外。滥用此系统可能导致撤销 或限制个人访问本系统,以及任何其他适当的限制 补救措施。TI员工滥用本系统可能导致纪律处分, 包括终止。



&抄袭;德克萨斯仪器公司。所有权利 保留的。 | |
有关我每天使用的自动登录代码,请参见下文:-

Sub Login()
    uname = Range("I18").Value
    pword = Range("I19").Value
    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://MYDOMAIN.COM/Login.aspx"
    With objIE
      .Visible = True
      .navigate WebSite
    Do While .Busy Or .readyState <> 4
        DoEvents
    Loop
    On Error Resume Next 'This is here in case fields cant be found.
    Set Element = .Document.getElementsByName("username_input")
    Element.Item(0).Value = uname

    Set Element = .Document.getElementsByName("password_input")
    Element.Item(0).Value = pword

    Set Element = .Document.getElementsByName("login_button")(0)
    Element.Click

    Do While .Busy Or .readyState <> 4
        DoEvents
    Loop

    .navigate "http://MYDOMAIN.COM/AdminPanel.aspx"
    End With

End Sub
子登录()
uname=范围(“I18”).值
pword=范围(“I19”).值
Set objIE=CreateObject(“InternetExplorer.Application”)
网站=”http://MYDOMAIN.COM/Login.aspx"
与奥布杰
.Visible=True
.浏览网站
请稍等片刻。忙碌或。准备就绪状态4
多芬特
环
“错误时继续下一步”如果找不到字段,则在此处显示。
Set元素=.Document.getElementsByName(“用户名\输入”)
Element.Item(0).Value=uname
Set元素=.Document.getElementsByName(“密码输入”)
元素。项(0)。值=pword
Set元素=.Document.getElementsByName(“登录按钮”)(0)
元素。单击
随叫随到
Sub Login()
    uname = Range("I18").Value
    pword = Range("I19").Value
    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://MYDOMAIN.COM/Login.aspx"
    With objIE
      .Visible = True
      .navigate WebSite
    Do While .Busy Or .readyState <> 4
        DoEvents
    Loop
    On Error Resume Next 'This is here in case fields cant be found.
    Set Element = .Document.getElementsByName("username_input")
    Element.Item(0).Value = uname

    Set Element = .Document.getElementsByName("password_input")
    Element.Item(0).Value = pword

    Set Element = .Document.getElementsByName("login_button")(0)
    Element.Click

    Do While .Busy Or .readyState <> 4
        DoEvents
    Loop

    .navigate "http://MYDOMAIN.COM/AdminPanel.aspx"
    End With

End Sub