View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ron ron is offline
external usenet poster
 
Posts: 118
Default How do I get something like IE View Source . . . Navigatethere with VBA

On Aug 17, 9:55*pm, ryguy7272 wrote:
Hello friends! *I have a SharePoint URL, which I define as this:

URL =https://collaboration.co.net/sites/US/Shared%20Documents/

Here is my VBA:

setrestart:
Set IE = Nothing
Set IE = CreateObject("InternetExplorer.Application")

With IE
* * .navigate URL
* * .Visible = False
* * 'Wait for page to load
* * While .Busy Or .readyState < 4 Or IE.Busy = True: Wend
* * Set HTMLdoc = .document
End With

Application.StatusBar = "Processing your Request. Please wait..."
xlFile = strpath & "/" & strFullString & ".xls" '& ActiveWorkbook.Name
activeWB = strFullString & ".xls"

Now . . . I’m trying to see if files are checked out from the
SharePoint site, so I’m thinking of using a line of VBA, as such

If InStr(1, URL, "Checked Out To:") 1 Then
‘ . . . do something
End If

Of, course, the URL is just the string from above. *What I really want
to do is something like go into IE View Source . . . THEN and only
then, I can start to use my If InStr command. *I’m sure I’ll have a
combination of If InStr commends, actually.

So, my question is, how do I get something like IE View Source and
assign that to some variable, URL2, or whatever?

Thanks!!!


If your macro needs to have IE opened and has already done so, then

my_var = ie.document.body.innerhtml

will assign the source code behind the current web page to the
variable "my_var". If there is no need to have IE open, then the
following construction will also assign the source code to "my_var".

my_url = "http://www.whatever"
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing

Since IE is not opened, this latter construction will run much more
quickly. It is paticularly advantageous if you are collecting data
from multiple urls...Ron