0

The code below is my problem. It is meant to copy fund information from a website into a spreadsheet. It worked fine when the funds were on a non-pdf website but it doesn't work for pdf websites. It's the Select-All (ie2.ExecWB 17, 0) that fails and I can't crack it. If I do keyboard ctrl-A on the pdf website it selects all and a sendkeys version kind of half works but what I need is a solution to getting this "ie2.ExecWB 17, 0" to do what it is supposed to do. any help greatly appreciated. cheers

Sub ListFunds()

Dim DataObj As New MSForms.DataObject
Dim S As String
Dim ie1, ie2
Set ie1 = CreateObject("internetexplorer.application")
Set ie2 = CreateObject("internetexplorer.application")
HWNDSrc = ie2.HWND
ie1.Visible = True
ie2.Visible = True
ie1.navigate "http://www.legalandgeneral.com/workplacebenefits/employees/help-support/fund-zone/fund-factsheets/wpp-tbop-pptip.html"
Do Until ie1.readystate = 4
    DoEvents
Loop
Dim LinkFound As Boolean
Dim linkCollection
Set linkCollection = ie1.document.all.tags("A")
For Each link In linkCollection
        If InStr(1, link.outerhtml, "fundslibrary") <> 0 Then
            ie2.navigate link
            Do Until ie2.readystate = 4
                DoEvents
            Loop
            ie2.ExecWB 17, 0 '// SelectAll
            ie2.ExecWB 12, 2 '// Copy selection
            DataObj.GetFromClipboard
            S = DataObj.GetText
            Selection.Value = S
            Selection.Offset(1, 0).Select
        End If
Next link
ie1.Quit
ie2.Quit

End Sub

2
  • Do you know if the pdf is opening from an application or the IE browser? (this can be set at the client level in the browser) This might be what is causing your issue.
    – Joseph
    May 3, 2013 at 18:03
  • You can get something like Fiddler to inspect the http headers that are being transferred. This might shed some light on the subject. I know I used it extensively when trying to access some data from an HTTPS site a while back.
    – Marshall
    May 3, 2013 at 20:43

1 Answer 1

1

Check this out, this might help you:

http://www.xtremevbtalk.com/showthread.php?t=299104

I'm not crazy about SendKeys at all, but I can't think of another way to capture the data from a PDF through a browser.

2
  • Thanks, I seem to have got there using the information on that link. My code is still a bit temperamental but it has worked. Sendkeys seems to be the only solution at present. I was expecting some command before the ExecWB's to make them work. Thanks.
    – Paul Symms
    May 4, 2013 at 15:29
  • @PaulSymms glad you got it to work! Could you please mark my answer as the accepted answer?
    – Joseph
    May 4, 2013 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.