Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

How to create a vba code to simulate right clicking on the current IE window then select “View Source” and then copy it to the clipboard?

I need a way to copy the data from the view source file to an existing excel spreadsheet.
0
kbay808
Asked:
kbay808
  • 2
1 Solution
 
Kyle AbrahamsSenior .Net DeveloperCommented:
This function should do the trick:

Function GetHTTPResult(sURL As String) As String
    Dim XMLHTTP As Variant, sResult As String
    Set XMLHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
    XMLHTTP.Open "GET", sURL, False
    XMLHTTP.Send
    Debug.Print "Status: " & XMLHTTP.Status & " - " & XMLHTTP.StatusText
    sResult = XMLHTTP.ResponseText
    Debug.Print "Length of response: " & Len(sResult)
    Set XMLHTTP = Nothing
    GetHTTPResult = sResult
End Function

Open in new window

0
 
kbay808Author Commented:
How do I run this macro?
0
 
kbay808Author Commented:
This is what I tried.
=GetHTTPResult()
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now