Actually it's a member of msforms library, not from native vba.
you can use it without a userform but you'll need a reference
to Microsoft Forms Object Library. The reference is automatically added
to a workbook when you insert a Userform from VBeditor's Insert menu.
複製代碼
Problem
An Excel VBA subroutine that involves interaction with the Windows Clipboard fails to run with the error:
“Compile error: User-defined type not defined.” The line of code highlighted by Excel as
being the cause of the error includes a reference to the “DataObject” object type.
Solution
(Tested on my machine with Excel 2003 SP3)
In the Microsoft Visual Basic editor:
Stop debugging by clicking the “Stop” button on the toolbar (if debugging isn’t already stopped).
Tools menu | References
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.)
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
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
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