Once an object has been made with using CreateObject Function
, we can access/handle to the object.
But when I wrote the code for handling other object, I don't know all of what kind of the properties/methods the object has.
In that case [F8
] key and the Locals window really helps me.
Placing the mouse cursor on the code line on the procedure then press [F8] key, the executed code line will be highlighted as follows.
When after the code line Set strDoc = ie.Document
was executed, please have a look at the Locals
Now you can see a variant named strDoc in the Expression area. Clicking the + mark, you can expand the Expression to see the child expressions.
Properties, Values and Type can be seen here.
Please note, this is just one example how to coding, so don't forget that you can also use other handy functions like object browser
, watch window
The following code get the TEXT or the HTML source from my website and print it in the immediate window.
The immediate window of your VBE will be as follows.
Const strMsg As String = "To get text click [Yes], To get Html click [No]"
Const sURI As String = "http://www.puremis.net/excel/"
Dim ie As Object
Dim strDoc As Object
Dim bln As Boolean
Set ie = CreateObject("internetexplorer.application")
Set strDoc = ie.Document
If MsgBox(strMsg, vbYesNo) = vbYes Then bln = True
If bln Then 'As Text
Else 'As Html
Set strDoc = Nothing
Set ie = Nothing