Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

will...You..PAUSE!!! 2

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
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?

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]
 
Hi,

I am new to scripting so I may be off base with my reply, but do you necessarily have to have see what Internet Explorer is doing? Have you tried to set your IE visibility to false?

objIE.visible = false
 
Sorry, I re-read your posting above your code a second and third time - I know why you have it visible now, so my suggestion above will not help.
 
Ok, this may be an Internet Explorer issue and may be fixed by changing the security settings:

Change Tools : Internet Options : Security : Custom level : Scripting : Allow programmatic clipboard access from Prompt to Enable

I hope that works for you to at least get rid of the error and allows you to move on.
 
Pellet

Actually, you were kind of right the first time, the operator doesn't really need to see the web page, but as I think you imply, if it wasn't visible we'd almost certainly not see the password prompt. Which is a shame.

Still, the operators are techies, not end-users who need their hands held so I don't really see it as a problem.

Also, bearing that in mind, I think the non-programmatic solution you offer will also be just fine (although still, I'd like to find a programmatic solution because "it's there"!).

Thanks, Pellet! :)

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]
 
...except that the script will be run under a 'RunAs' command with our admin level accounts so we'd have to remember to configure IE under the context of that account's profile BEFORE running the script...eek. So, a programmatic solution is still preferable.

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]
 
Hmm, I could always write a subroutine to run IE and prompt the user to configure the option you suggest (then write a flag file for that subroutine to check exists - and if it does, next time the script is run, it won't prompt the user to change the setting)

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]
 
Hi JJ,

What if you were to create a .hta and have that open the IE window and then call your subroutine after that since .hta's don't require ActiveX controls? Maybe it would be something like this?

<html>
<HTA:APPLICATION
Caption="no"
>

<script language = "VBScript">

Sub Window_OnLoad
window.resizeTo 400,250
idTimer = window.setTimeout("PausedSection", 5000, "VBScript")
End Sub

And then you would just return to your script and run your processes?

Again, I am new to scripting, so I may be way off.

Please let me know if this is something that may or may not work for you.

Pellet
 
Nope, you lost me. Apart from the fact I'm not clear on what a .HTA is anyway, are you suggesting the VB script calls/creates the .HTA then waits for it to close or finish loading?

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]
 
Code:
Set objExplorer=CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
obJexplorer.Visible=1
Do While (obJExplorer.Busy)
Loop

Tao Te Ching Discussions : Chapter 9 (includes links to previous chapters)
What is the nature of conflict?
 
Already got that, I'm afraid (just before the "[tt]'==========================================[/tt]" line)...

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]
 
I'm liking that.

A LOT!

Thanks, PHV...

:)

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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top