返回列表 上一主題 發帖

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

回復 2# stillfish00


    Dear S 大

我想請問  關於網頁物件的這個寫法裡面

.document.getElementById("raw_textarea").innerText = myData.GetText '填入
    .document.getElementById("result_submit").Click 'submit

這兩行字的解釋,應該要去msdn的哪裡查詢  或是從哪個物件去了解

我常常看到你們與G大&H大 都能夠運用自如

我還在學習的過程當中,發現查找資料是最難的一環,剩下來的應用,看範例應該都能略知一二 慢慢理解

請問這個部分 假設我是新手,想要了解網頁物件用法,應該從哪個地方切入

謝謝您的指教^^

TOP

回復 12# c_c_lai


   問題都解決了 感謝各位!

TOP

回復 11# icestormer
  1.       '  MsgBox x.All.tags("h4")(0).innerText
  2.       [L22] = x.All.tags("h4")(0).innerText
複製代碼

TOP

本帖最後由 icestormer 於 2013-10-19 21:26 編輯

Sub Test()
  Dim oIe, myData As DataObject, x
  
  Set myData = New DataObject  '需引用 MS Form Object Library
  
  With Sheets("問題")
    .Range(.[A4], .[F4].End(xlDown)).Copy
  End With
  myData.GetFromClipboard
  
  Set oIe = CreateObject("internetExplorer.Application")
  With oIe
    '.Visible = False
    .navigate "http://www.evepraisal.com"
    Do While oIe.readystate <> 4: DoEvents: Loop
   
    .document.getElementById("raw_textarea").innerText = myData.GetText '填入
    .document.getElementById("result_submit").Click 'submit
   
    Application.Wait Now + TimeValue("00:00:05")  '等待5秒完成
   
    Set x = .document.getElementById("result_container")
  MsgBox x.All.tags("h4")(0).innerText

請問一下 MSGBOX這行 如果要把結果寫入 L22格內 要怎寫 呢?(不要顯示在MSGBOX上) 感謝

    .Quit
  End With
  
End Sub

TOP

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

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

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

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

回復 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

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



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

TOP

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

TOP

回復 4# c_c_lai


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

TOP

        靜思自在 : 得理要饒人,理直要氣和。
返回列表 上一主題