返回列表 上一主題 發帖

[發問] 如何將從EXCEL內的資料貼入網站中(過程都由VBA自動執行)

[發問] 如何將從EXCEL內的資料貼入網站中(過程都由VBA自動執行)

問題.rar (10.19 KB)
主要想讓紅圈處 的資料  複制>>打開右上方的網址>再貼上後按下 submit  


最好還能將下面紅圈處二筆ISK 也都傳回EXCEL上

不知有沒有法子能做到呢? 感謝幫忙了

本帖最後由 stillfish00 於 2013-10-18 16:22 編輯

回復 1# icestormer
  1. Sub Test()
  2.   Dim oIe, myData As DataObject, x
  3.   
  4.   Set myData = New DataObject  '需引用 MS Form Object Library
  5.   
  6.   With Sheets("問題")
  7.     .Range(.[A4], .[F4].End(xlDown)).Copy
  8.   End With
  9.   myData.GetFromClipboard
  10.   
  11.   Set oIe = CreateObject("internetExplorer.Application")
  12.   With oIe
  13.     '.Visible = False
  14.     .navigate "http://www.evepraisal.com"
  15.     Do While oIe.readystate <> 4: DoEvents: Loop
  16.    
  17.     .document.getElementById("raw_textarea").innerText = myData.GetText '填入
  18.     .document.getElementById("result_submit").Click 'submit
  19.    
  20.     Application.Wait Now + TimeValue("00:00:05")  '等待5秒完成
  21.    
  22.     Set x = .document.getElementById("result_container")
  23.     MsgBox x.All.tags("h4")(0).innerText
  24.     .Quit
  25.   End With
  26.   
  27. End Sub
複製代碼

TOP

回復 2# stillfish00


   


你好 我不太懂問題出在那 但我才跑第一行就出現 上圖的問題 請問我要怎做呢??

TOP

回復 3# icestormer
如 stillfish00 之解說: 使用 DataObject 宣告,須引用 Microsoft Form Object Library
你先檢查該 Library 是否已經勾選, 否則執行時會產生 "未定義" 的訊息,我將如何引用
的方法,說明如下,希望對你會有所幫助。
  1. 1.  開發人員  --->   工具   --->  設定引用項目   --->   可引用的項目(A)
  2. 2.  然後觀察 Micorsoft Forms 2.0 Ojbect Library 有否勾選?
  3. 3.  如果該項目不存在!
  4. 4.  則點選 "瀏覽" 選鈕   --->   新增引用項目 - VBAProject,
  5.     搜尋位置(I) 指向 Windows/System32\FM20.dll, 接著再點選
  6.     "開啟" 便會自動勾選 Micorsoft Forms 2.0 Ojbect Library 了。
複製代碼
祝你一帆風順!

TOP

回復 4# c_c_lai


   你好  我是用2003的 但我找不到你說的 開發人員 選項呢

TOP

回復 5# icestormer
我手頭上並沒有 2003 的版本,有關這方面
你可能要去請教 GBKEE 版大了,因為他也是
使用 2003 的版本。

TOP

回復  icestormer
我手頭上並沒有 2003 的版本,有關這方面
你可能要去請教 GBKEE 版大了,因為他也是
...
c_c_lai 發表於 2013-10-19 08:04



   那請問我要怎找他呢? 是寫信給他? (我還沒用過這類的功能~~)

TOP

回復 7# icestormer
我只會對案例回復,至於平常如何呼叫真的不知如何聯繫。
但我找到了兩篇有關解決方案,提供你參考:
  1. Actually it's a member of msforms library, not from native vba.

  2. you can use it without a userform but you'll need a reference
  3. to Microsoft Forms Object Library. The reference is automatically added
  4. to a workbook when you insert a Userform from VBeditor's Insert menu.
複製代碼
  1. Problem

  2. An Excel VBA subroutine that involves interaction with the Windows Clipboard fails to run with the error:
  3. “Compile error: User-defined type not defined.”  The line of code highlighted by Excel as
  4. being the cause of the error includes a reference to the “DataObject” object type.

  5. Solution

  6. (Tested on my machine with Excel 2003 SP3)

  7. In the Microsoft Visual Basic editor:

  8.     Stop debugging by clicking the “Stop” button on the toolbar (if debugging isn’t already stopped).
  9.     Tools menu | References
  10.     In the list of available references, find “Microsoft Forms 2.0 Object Library”, check it, and click OK.  (For me, this was the 2nd unchecked item from the top of the list; it wasn’t sorted alphabetically in the list like most of the rest of the listed items.)
  11.     Run the macro again.

  12. That’s it!  Hope this helps!
複製代碼

TOP

回復 7# icestormer
為方便閱覽,特將它翻譯如下:
  1.     Actually it's a member of msforms library, not from native vba.
  2.     (確實它是微軟表單程式庫的乙員,而非 VBA 的生成元件)

  3.     you can use it without a userform but you'll need a reference
  4.     to Microsoft Forms Object Library. The reference is automatically added
  5.     to a workbook when you insert a Userform from VBeditor's Insert menu.
  6.     (你可以不需表單而去使用它,但是你還是須要參考到微軟的表單物件程式庫。
  7.      當你從VB編輯插入選單內插入一張表單時,此參考項會自動加入到活頁簿裡。)


  8.     Problem (問題)

  9.     An Excel VBA subroutine that involves interaction with the Windows Clipboard fails to run with the error:
  10.     “Compile error: User-defined type not defined.”  The line of code highlighted by Excel as
  11.     being the cause of the error includes a reference to the “DataObject” object type.
  12.     (當一個試算表 VBA 程式段內涵蓋視窗剪貼簿之鏈結於執行時產生錯誤:"程式編輯錯誤:使用者自訂型態尚未定義"。
  13.      反白標示發生錯誤的這行是在說明它在參照 "資料物件 (“DataObject”)" 時發生了參照錯誤。)

  14.     Solution (解決方案)

  15.     (Tested on my machine with Excel 2003 SP3) (已經在Excel 2003 SP3測試過)

  16.     In the Microsoft Visual Basic editor: (在微軟的 VB 編輯器內)

  17.         Stop debugging by clicking the “Stop” button on the toolbar (if debugging isn't already stopped).
  18.         (停止偵錯模式,即選按工作列上的 "停止" 鈕終止偵錯)
  19.         Tools menu | References  (工具菜單  |  參考項目 )
  20.         In the list of available references, find “Microsoft Forms 2.0 Object Library”, check it, and click OK.
  21.         在參考列示項目選單內,找尋“Microsoft Forms 2.0 Object Library”,找到後點選它就完成了。
  22.         (For me, this was the 2nd unchecked item from the top of the list; it wasn't sorted alphabetically
  23.          in the list like most of the rest of the listed items.)
  24.         Run the macro again. (再重新執行巨集)

  25.     That's it!  Hope this helps!  (就這樣! 希望對你有所幫助!)
複製代碼

TOP

本帖最後由 GBKEE 於 2013-10-19 16:39 編輯

回復 7# icestormer
模組插入表單就可以了

感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 一句溫暖的話,就像往別人身上灑香水,自己會沾到兩三滴。
返回列表 上一主題