Thread: [Solved] Extract Webdata from word
View Single Post
 
Old 12-02-2015, 05:30 AM
PRA007's Avatar
PRA007 PRA007 is offline Windows 7 64bit Office 2010 32bit
Competent Performer
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

This is one step towards answering my question.

Code:
Sub USPTOAbstHTML1()
Application.ScreenUpdating = False
Dim Rng As Range, Tbl As table, StrTxt As String, HttpReq As Object, i As Long, oHtml As MSHTML.HTMLDocument, IE As SHDocVw.InternetExplorer
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
Set oHtml = New HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
With ActiveDocument.Range
    For Each Tbl In .Tables
        With Tbl
            For i = 1 To .Rows.Count
                With .Cell(i, 2).Range
                            If .Hyperlinks.Count > 0 Then
                            MsgBox .Hyperlinks(1).Address
                                HttpReq.Open "GET", .Hyperlinks(1).Address, False
                                HttpReq.send
                                oHtml.body.innerHTML = HttpReq.responseText
                                MsgBox HttpReq.responseText
                                StrTxt = oHtml.getElementsByClassName("claim").Item.innerHTML
                                With IE
                                    .Visible = False
                                    .navigate "about:blank"
                                    .Document.body.innerHTML = StrTxt
                                    .Document.execCommand "SelectAll"
                                    .Document.execCommand "Copy"
                                End With
                                With Tbl.Cell(i, 5).Range
                                   Selection.PasteAndFormat (wdPasteDefault)
                                End With
                            End If
                            .Collapse wdCollapseEnd
                            .Find.Execute
                End With
            Next
        End With
    Next
End With
Set HttpReq = Nothing
Application.ScreenUpdating = True
End Sub
The Problem with above code is it asks for permission for allowing ie to navigate the page.
Can we by default allow access to internet explorer so that it doesn't popup everytime?

Last edited by PRA007; 12-02-2015 at 09:18 AM.
Reply With Quote