Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-01-2015, 03:21 AM
PRA007's Avatar
PRA007 PRA007 is offline Working with word tables. Windows 7 64bit Working with word tables. Office 2010 32bit
Competent Performer
Working with word tables.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Lightbulb Working with word tables.

I have in word table hyperlinked numbers.

I want to populate table wit winhttp Request.

I tried picking code from here and there to explain what I want.

Code:
Sub USPTOAbstHTML1()
Application.ScreenUpdating = False
Dim Rng As Range, Tbl As table, StrTxt As String, HttpReq As Object, i As Long, doc As MSHTML.HTMLDocument
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
Set oHtml = New HTMLDocument
With ActiveDocument.Range
    For Each Tbl In .Tables
        With Tbl
            For i = 1 To .Rows.Count
                With .Cell(i, 2).Range
                    With .Find
                        .ClearFormatting
                        .Replacement.ClearFormatting
                        .Text = "US [0-9],[0-9]{3},[0-9]{3}"
                        .Replacement.Text = ""
                        .Forward = True
                        .Wrap = wdFindStop
                        .Format = False
                        .MatchWildcards = True
                        .Execute
                    End With
                        If .Find.Found Then
                            If .Hyperlinks.Count > 0 Then
                                HttpReq.Open "GET", .Hyperlinks(1).Name, False
                                HttpReq.send
                                oHtml.body.innerHTML = HttpReq.responseText
                                StrTxt = oHtml.getElementsByTagName("p")(0).innerText
                            End If
                        End If
                            .Collapse wdCollapseEnd
                            .Find.Execute
                End With
                With .Cell(i, 3).Range
                .InsertAfter vbCr & "Abstract:" & StrTxt
                End With
            Next
        End With
    Next
End With
Set HttpReq = Nothing
Application.ScreenUpdating = True
End Sub
I could not figure out how to make With .Cell(i, 3).Range runs with With .Cell(i, 2).Range find.found.

This code inputs data everywhere in .Cell(i, 3).Range irrespective of .find.found. in Cell(i, 2).Range

How to make them sync.

file at:
https://sites.google.com/site/rtsk2015/fo


HTTP.docx
In file I have in column 4 also put data what I want in column 3 for explanation.

Last edited by PRA007; 12-01-2015 at 08:43 PM.
Reply With Quote
  #2  
Old 12-02-2015, 04:22 AM
PRA007's Avatar
PRA007 PRA007 is offline Working with word tables. Windows 7 64bit Working with word tables. Office 2010 32bit
Competent Performer
Working with word tables.
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default

Apology for asking silly questions as inexperienced in VBA.
After reviewing the code I figure out the mistake. Putting the .cell 3 within if find.found works ok.
Reply With Quote
Reply

Tags
word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word tables: prevent word from highlighting whole cell when I highlight text skylark53 Word 2 08-04-2015 08:12 AM
Working with word tables. Header Rows in Tables Not Working Andy Pilkington Word 2 10-10-2014 12:36 AM
Working with word tables. Tables in Word angalis428 Word 1 01-06-2012 01:12 PM
Working with word tables. working with excel tables in MS word radman154 Word Tables 1 03-25-2011 12:04 AM
Word tables nbudd Word Tables 1 05-09-2010 06:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:11 AM.


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