I am using a Macro Excel functions to load web pages, but many websites are no longer supporting the IE, the main web browser working on VBA.
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = 0
URL = "http://website/"
ie.Navigate URL
State = 0
Do Until State = 4
DoEvents
State = ie.readyState
Loop
would the problem be solved if i installed IE11 or MS Edge?
Related
Dear Friends Vba Masters,
I have Issue connected with no possibility of achieved state "ready state" for my page. For others it is works for ex. google.com but I don`t know why for my page not. Strange things is that this page always load to view even in state .Visible = false , and object value od empty. I would like to create macro to login for this page and control some activities - on this page you can create some excel file to analysis. I will be very kind full. Mac.
Sub OpenKWM()
Dim URL As String
Dim IE As Object
Set IE = CreateObject("internetExplorer.application")
URL = "kwm.kromi.de"
With IE
.Navigate URL
.Visible = True
End With
Do: Loop Until IE.readyState = READYSTATE_COMPLETE
End Sub
Strange things is that this page always load to view even in state .Visible = false , and object value od empty.
If you check the relevant doc, you will find that this is actually a reasonable result. Whether the created Internet Explorer window is visible depends on whether you have called the Navigate method or the GoSearch method. When you call these methods, the window will become visible.
Edit:
After testing, I found that the cause of the problem may be Enable Protected Mode in IE settings. You can try to disable it: open IE -> Tools -> Internet Options -> security tab -> uncheck Option Enable Protected Mode. Like this:
I am using below mentioned code for data extraction,this code is working fine for me when java scripts are disabled in Internet Explorer but when i enable scripts then Memory utilization is very high and increase after each url extraction.Suggestion require so that system will use very low memory.I use following code i.e set ie=nothing or ie.refresh2 but still same issue.
Ie.navigate url1234
Do While Ie.ReadyState <> 4 Or _
Ie.Busy = True
DoEvents
Loop
Set html = Ie.Document
html1 = html.body.innerHTML
First I'm very new to trying to automate IE via Excel VBA.
That being said, I'm working to automate a login to a company-specific webpage (only accessible to our employees). The goal is to automate the login (employee number, password and click Login). I find Firefox to be particularly helpful in identifying fields so that's what I'm using in the screenshot.
I found some code online to navigate to a webpage and enter something into a search box. I've modified that as follows (the included link is not real).
Finally to the issue. If I enter a webpage like www.google.com for example, all will execute fine. But when I change to my company link, the code freezes at the Do While and I get the error shown. So my question is why it works for a general webpage but not for my company specific one? If I comment-out that line, I still get the disconnected error when debugging. Assuming that issue is an easy one to resolve, have I also properly identified the field?
Hopefully I've included enough info for you. If not, please let me know what else may be required. Thanks in advance for your help!
Error
'start a new subroutine called SearchBot
Sub SearchBot()
'dimension (declare or set aside memory for) our variables
Dim objIE As InternetExplorer 'special object variable representing the IE browser
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "http://sampletext.asp"
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'enter value in the employee number box
objIE.document.getElementByName("txtEmployeeNum").Value = "123456"
Employee Number
Correct name of the method is getElementsByName.
You also want to operate on element of collection returned by this method, not whole collection. Using (0) index will allow to work on 1st element of collection.
Change:
objIE.document.getElementByName("txtEmployeeNum").Value = "123456"
to:
objIE.document.getElementsByName("txtEmployeeNum")(0).Value = "123456"
With such corrected code, you should step through code with F8 in VB Editor. For example by hovering over, see if objIE.Busy ever gets FALSE and especially if objIE.readyState ever reaches 4 - if only 3, try objIE.readyState < 3 instead.
EDIT:
Try replacing:
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
with:
Dim objIE As Object
Set objIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
You may also need to change objIE.Navigate with objIE.Navigate2
How to open an existing IE Instance correctly without worrying to loose the Session loaded?
This is how i do:
Dim Webbrowser
Webbrowser = 1
Set WebBrowser1 = CreateObject("InternetExplorer.Application")
WebBrowser1.Visible = False
WebBrowser1.Navigate Link, Flags, TargetFrame, PostData, Headers
While WebBrowser1.ReadyState <> 4
DoEvents
Wend
but in some cases an existing IE(8) Instance does not load with Session Data
Background:
I have 7 Machines which are running Windows 7 64 Bit, IE8 and Access 2000
5 of them are able to access to the actual IE8 Session via InternetExplorer.Application Object in VBA (Access 2000). But 2 of them can't do that. I can't find the difference. All Versions are exactly the same.
Behavior is same as i would use IE greater that IE8
I have a vbscript using the InternetExplorer object to navigate to a few pages and passing data to those pages. Recently since patching IE8 I've noticed that something is causing the creation of zombie iexplore.exe processes. While running my script and watching the process list in task manager I noticed that when my script creates the InternetExplorer.Application object, two processes appear in the process list. Is this normal behavior? Why does this happen? I'm wondering because even though during my testing it appears both of these processes get killed when I call the InternetExplorer object's quit method, I still suspect that these multiple processes are the root cause of the zombies.
Here is some sample code:
Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 "Address"
ie.AddressBar = 1
ie.Toolbar = 1
ie.StatusBar = 1
ie.Width = 600
ie.Height = 400
ie.Left = 300
ie.Top = 150
ie.Visible = 1
Do While ie.Busy
WScript.Sleep 1
Loop
ie.Navigate2 "Address?variable=value"
Do While ie.Busy
WScript.Sleep 1
Loop
...rest of code...
ie.Quit
Set ie = Nothing
I would guess that IE is putting the tab and the browser window in separate processes.
I have a similar issue when using createobject to start MsAccess. Two processes appear in the task list and both go away with the quit command.
However if some problem occurs during the session that causes my program to crash only one of the processes gets shutdown.
This must be some Microsoft system feature.