Here's a sub routine.
What should it do?
1 - Open an intranet page
2 - Wait until it's finished loading (do while objIE.busy)
3 - Assign the contents of the page to a variable called strCopy
4 - Copy the contents of that variable to the clipboard (objIE.document.parentwindow.clipboardData.SetData "text", strCopy)
5 - Paste in to a spreadsheet (objWorksheet.Paste)
The problem is that a prompt appears asking "Do you want to allow this webpage to access your clipboard", behind which is the webpage all nice and...blank. Because apparently it hasn't yet loaded it. But the IE object is presumably not actually busy so must have loaded the page in order to get to the 'clipboardData.SetData' line, which itself is after the 'strCopy = objIE.Document.Body.InnerHTML' line, so why is it blank?
Whatever, can anyone tell me how to achieve what I'm trying to achieve?
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]
What should it do?
1 - Open an intranet page
2 - Wait until it's finished loading (do while objIE.busy)
3 - Assign the contents of the page to a variable called strCopy
4 - Copy the contents of that variable to the clipboard (objIE.document.parentwindow.clipboardData.SetData "text", strCopy)
5 - Paste in to a spreadsheet (objWorksheet.Paste)
The problem is that a prompt appears asking "Do you want to allow this webpage to access your clipboard", behind which is the webpage all nice and...blank. Because apparently it hasn't yet loaded it. But the IE object is presumably not actually busy so must have loaded the page in order to get to the 'clipboardData.SetData' line, which itself is after the 'strCopy = objIE.Document.Body.InnerHTML' line, so why is it blank?
Whatever, can anyone tell me how to achieve what I'm trying to achieve?
Code:
Sub RunCheckSAN()
strTitle = "SAN Storage"
wscript.echo strBorder
strEcho = "Checking SAN Storage" ' & vbCrLf
Call NextHeader(strTitle,strEcho)
Dim strSAN
Dim strSANURL
Dim strSAN_Name
Dim arrSAN
For Each strSAN in arrSANs
bQuit = False
arrSAN = split(strSAN,",")
strSANURL = arrSAN(0)
strSAN_Name = arrSAN(1)
Set objIE = wscript.CreateObject("InternetExplorer.Application","objIE_")
If Err.Number <> 0 Then
On Error GoTo 0
Msg = "IE application not found when trying to check SAN storage."
MsgBox Msg,vbExclamation,strAppDescription
Wscript.Quit
End If
On Error GoTo 0
objIE.visible = true
objIE.ToolBar = 0
objIE.statusbar=false
objIE.Navigate "about:blank"
Do Until objIE.ReadyState = 4
WScript.Sleep 100
Loop
objIE.Navigate strSANURL
do while objIE.Document is nothing
wscript.sleep 50
loop
do while objIE.Document.body is nothing
wscript.sleep 50
loop
do while objIE.busy' is nothing
wscript.sleep 2000 ' 50
loop
'==========================================
Dim strCopy : strCopy = objIE.Document.Body.InnerHTML
wscript.echo "'" & strCopy & "'"
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
Dim objExcel : Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Dim objWorkbook : Set objWorkbook = objExcel.Workbooks.Add()
Dim objWorksheet : Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Paste
'==========================================
Do While not bQuit
WScript.Sleep 500
Loop
Next
if bFreeSpaceError = true then
'wscript.echo " Error(s) found!"
end if
End Sub
JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, and so on)[/small]