Accessing HTMLDocument object in DownloadBegin

Add-in Express™ Support Service
That's what is more important than anything else

Accessing HTMLDocument object in DownloadBegin
I am trying to get the URL information that is being loaded 
Alexander Desuasido




Posts: 78
Joined: 2009-04-03
Objective: I am trying to get the url that is being loaded before it gets loaded. I am guessing that the best way to access this is the HTMLDocument object in the DownloadBegin event of IEModule.vb. When attempting the code below, I receive the errors as listed beneath.

Can you help me in figuring out why I cannot access the HTMLDocument in this fashion? I have tried assigning it to a mshtml.HTMLDocument object, using Me.HTMLDocument, etc. but nothing seems to work. Note: Getting the url seems to work after the error is experienced.

What is the "official" way to open and access this Me.HTMLDocument object within AddInExpress code?

Thanks in advance!

VB Code:

    Private Sub IEModule_DownloadBegin() Handles Me.DownloadBegin
        MsgBox("in IEModule_DownloadBegin")

        If Not (HTMLDocument Is Nothing) Then
            'Dim currentDomain As String = HTMLDocument.domain
        End If
    End Sub


VB Local Variable:

-		HTMLDocument	{"Exception has been thrown by the target of an invocation."}	mshtml.HTMLDocument


TargetInvocationException Error at this line 3:

    Public ReadOnly Property HTMLDocument() As mshtml.HTMLDocument
        Get
            Return CType(Me.HTMLDocumentObj, mshtml.HTMLDocument)
        End Get
    End Property


TargetInvocationException Detail

System.Reflection.TargetInvocationException was unhandled by user code
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
       at AddinExpress.IE.ADXIEModule.get_HTMLDocumentObj()
       at KidiraASM.IEModule.get_HTMLDocument() in C:Documents and SettingsADesuasiMy DocumentsVisual Studio 2005ProjectsKidiraASMKidiraASMIEModule.vb:line 104
       at KidiraASM.IEModule.IEModule_DownloadBegin() in C:Documents and SettingsADesuasiMy DocumentsVisual Studio 2005ProjectsKidiraASMKidiraASMIEModule.vb:line 127
       at AddinExpress.IE.ADXIEModule.DoDownloadBegin()
Posted 03 Apr, 2009 11:27:00 Top
Eugene Astafiev


Guest


Hello Alexander,

I am trying to get the url that is being loaded before it gets loaded. I am guessing that the best way to access this is the HTMLDocument object in the DownloadBegin event of IEModule.vb. When attempting the code below, I receive the errors as listed beneath.


I would recommend using the DocumentComplete event instead of the DownloadBegin one. In the last event handler you will not get alive HTMLDocument.
Posted 03 Apr, 2009 12:59:49 Top
Alexander Desuasido




Posts: 78
Joined: 2009-04-03
Eugene:

thanks so much for the prompt reply.

For performance reasons, I would like to conduct this transaction prior to the page loading.

Is there any other way to get the URL being loaded, preferably before the page is loaded?
Posted 03 Apr, 2009 15:24:19 Top
Eugene Astafiev


Guest


Hello Alexander,

Is there any other way to get the URL being loaded, preferably before the page is loaded?


Yes, there is one. You can use the BeforeNavigate2 event of the add-on module.
Posted 06 Apr, 2009 07:10:05 Top