Board logo

標題: [發問] 可以操作自動上傳資料嗎? [打印本頁]

作者: faye59    時間: 2018-6-9 21:23     標題: 可以操作自動上傳資料嗎?

由於公司內部網頁無法提供網址

嘗試過用myIE.document.all("txtFile").Value傳值進去,
可是[readonly]無法填入,有其他方法嗎?
爬過很多網站跟文章找不到相關的解答,
還是VBA不允許自動上傳檔案?
如需Function我在補上。

<!-- upload form -->
<div id="upload" style="margin-top:-20;margin-bottom:-20;display:none">
  <form name="frmUpload" method=POST action='lot_query_upload.jsp' enctype="multipart/form-data">
    <table border="1" cellpadding="0" cellspacing="0" class="w3dFormL" width="70%" align="center">
      <tr>
        <td>
          <table border="0" cellpadding="0" cellspacing="0" align="center">
            <tr>
              <td class="tbl" style="padding-left:10px">Choose a text file
                <input class="tbl" type='file' name="txtFile" size="30" > <!--1.0.1 Remove [readonly] option-->
              </td>
              <td style="padding-left:10px">
                <input class="btn" type="button" name="cmdOK" value="OK" onclick="doUpload()">
                <input class="btn" type="button" name="cmdCancel" value="Cancel" onclick="doCancel()">
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </form>
</div>
作者: faye59    時間: 2018-6-10 19:48

由於公司內部網頁無法提供網址

嘗試過用myIE.document.all("txtFile").Value傳值進去,
可是[readonly] ...
faye59 發表於 2018-6-9 21:23


補上我的寫的VBA
沒一開始補上想說沒什麼內容
  1. Option Explicit

  2. Dim a As Object
  3. Sub UpData()
  4. Dim tagid As Object

  5. Set a = CreateObject("InternetExplorer.Application")
  6. a.Visible = True
  7. a.Navigate "http://test/Query.jsp"
  8. While a.Busy = True Or a.readyState <> 4
  9. DoEvents
  10. Wend
  11. a.document.all("fldName").Value = "選單"
  12. a.document.all("queryCondition").Value = "名稱"

  13. Set tagid = a.document.getelementsbytagname("INPUT")
  14. tagid(1).Click
  15. While a.Busy = True Or a.readyState <> 4
  16. DoEvents
  17. Wend
  18. a.document.parentWindow.execScript "tabChange(1, 'P_LOT_OPER', 'ORACLE2')", "JavaScript"
  19. End Sub
複製代碼





歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)