Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2015, 03:26 PM
macropod's Avatar
macropod macropod is offline Extract Webdata from word Windows 7 64bit Extract Webdata from word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://answers.microsoft.com/en-us/o...3-5bd69975ea31
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-01-2015, 09:57 PM
PRA007's Avatar
PRA007 PRA007 is offline Extract Webdata from word Windows 7 32bit Extract Webdata from word Office 2010 32bit
Competent Performer
Extract Webdata from word
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Apology For Not mentioning. I Generally do Mention While Cross posting.
This time as I have done it from home, that might be the reason.

I Also cross posted this message and did mention:

http://stackoverflow.com/questions/3...microsoft-word

Did not get answer. I asked it different way still did not get the answer.

I get suggestion from Cindy Meister[Microsoft MVP since 1996] which was similar to the suggestion given by You.
Quote:
This is the third time you've posted this question. It's probably not getting any answers because the core of your question has nothing to do with VBA. Word VBA doesn't know how to parse web pages - it's specialized for working with the Word application. In one of your previous attempts you had some code from a library that works with the HTML DOM. You need to pursue that route - figure out how to extract the data you need using that library. Once you get that, writing it to Word won't be a problem. Target tags for that technology, not Word, and stop spamming the word tags.
I will stop posting this question anywehre now.
I started learning and will get the answer anyway on my own and will surely post it here.
Reply With Quote
  #3  
Old 12-02-2015, 05:30 AM
PRA007's Avatar
PRA007 PRA007 is offline Extract Webdata from word Windows 7 64bit Extract Webdata from word Office 2010 32bit
Competent Performer
Extract Webdata from word
 
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
  #4  
Old 12-02-2015, 09:30 AM
PRA007's Avatar
PRA007 PRA007 is offline Extract Webdata from word Windows 7 64bit Extract Webdata from word Office 2010 32bit
Competent Performer
Extract Webdata from word
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

In above code, one of problem is with Selection.PasteAndFormat (wdPasteDefault).

It doesn't go to specific location but goes to colum which are selected.

How to pate range to specific location in word?
Reply With Quote
  #5  
Old 12-02-2015, 10:49 PM
PRA007's Avatar
PRA007 PRA007 is offline Extract Webdata from word Windows 7 64bit Extract Webdata from word Office 2010 32bit
Competent Performer
Extract Webdata from word
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

this works perfect
Code:
Set rng = Tbl.Cell(i, 5).Range
rng.Collapse wdCollapseStart
rng.PasteAndFormat wdPasteDefault
As this has solved the question, can be marked as solved.
Reply With Quote
Reply

Tags
macro, website, word 2010



Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract VBA code to save in Word document Dave T Word VBA 4 01-26-2015 08:41 PM
Extract Webdata from word Need to extract two word domains from a list (BULK) Maxwell314 Excel 3 12-08-2014 06:17 PM
Extract Webdata from word How to Extract key data from word iliauk Word 3 11-08-2013 04:37 PM
Is there a way to extract various text in Word? barnkeeper410 Word 4 07-08-2013 10:58 PM
Extract Webdata from word Extract phone number from word file donlincolnmsof Word VBA 12 06-19-2012 05:21 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft