473,581 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB macro with internet explorer object runs out of memory

1 New Member
Hi All,

I have an excel macro that I'm running. The code does everything I want except that after about 200 iterations VB will run out of memory and I'll get an "automation error". I'm using the internet explorer object within my code. My code opens a web page within a browser, refreshes the page, clears browser cache, closes the web browser and then repeats these operations in a loop. Please don't ask why it does this; it's important to me that this works. After about 200 iterations VB will say that there is an "automation error; unspecified error". I think the problem is that I'm re-instantiating the internet explorer object every time the loop runs. I have pasted the code below. Can someone please offer some suggestions as to how I can run the loop as long as I want without running out of memory? THE CODE HAS TO OPEN AND CLOSE A WEB BROWSER REPEATEDLY until I decide to click a button and end the process.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdProcess1_Click()
  3.  
  4. Dim flag As Boolean
  5. flag = True
  6. Call Clear_Cache
  7.  
  8. Do While flag = True ''will keep opening web page while flag is true
  9.  
  10. Call Clear_Cache
  11. Set iexplore2 = CreateObject("InternetExplorer.Application")
  12. iexplore2.Visible = True
  13. iexplore2.Navigate URL:="http://www.google.com" ''load web page
  14.  
  15.     Do While iexplore2.ReadyState <> 4 ''wait till web page finishes loading
  16.         DoEvents
  17.     Loop
  18.  
  19. Call Clear_Cache ''clear browser cache
  20. iexplore2.Quit ''close web page
  21. Set iexplore2 = Nothing ''reset to preserve memory but THIS DOES NOT WORK!!!
  22.  
  23. Loop
  24.  
  25. End Sub
  26.  
  27. Private Sub cmdStop_Click()
  28.  
  29. Call Clear_Cache
  30.  
  31. End
  32.  
  33. End Sub
  34.  
  35. Private Sub cmdProcess2_Click()
  36.  
  37. Dim flag As Boolean
  38. flag = True
  39.  
  40. Do While flag = True ''will keep opening web page while flag is true
  41. Set iexplore = CreateObject("InternetExplorer.Application")
  42. iexplore.Visible = True
  43.  
  44.  
  45. iexplore.Navigate URL:="http://www.google.com" ''load web page
  46.  
  47.     Do While iexplore.ReadyState <> 4 ''wait till web page finishes loading
  48.         DoEvents
  49.     Loop
  50.  
  51. Call Clear_Cache ''clear browser cache
  52.  
  53. iexplore.Refresh 'refresh banner page
  54.  
  55.     Do While iexplore.ReadyState <> 4 ''wait till refresh finishes loading
  56.         DoEvents
  57.     Loop
  58.  
  59. Call Clear_Cache  ''clear cache after refresh
  60.  
  61. iexplore.Quit ''close web page
  62. Set iexplore = Nothing ''reset to preserve memory but THIS DOES NOT WORK!!!
  63. Loop
  64.  
  65. End Sub
  66.  
  67. Sub Clear_Cache()
  68.  
  69. Call Clear_Temp_Files
  70. Call Clear_Cookies
  71. Call Clear_History
  72. Call Clear_Form_Data
  73. Call Clear_Saved_Passwords
  74. Call Clear_All
  75.  
  76. End Sub
  77. Sub Clear_Temp_Files()
  78. Shell ("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 ")
  79. End Sub
  80. Sub Clear_Cookies()
  81. Shell ("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2")
  82. End Sub
  83.  
  84. Sub Clear_History()
  85. Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1"
  86. End Sub
  87.  
  88. Sub Clear_Form_Data()
  89. Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16"
  90. End Sub
  91.  
  92. Sub Clear_Saved_Passwords()
  93. Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32"
  94. End Sub
  95.  
  96. Sub Clear_All()
  97. Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255"
  98. End Sub
  99.  
  100. Sub Clear_Clear_Add_ons_Settings()
  101. Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351"
  102. End Sub
  103.  
  104.  
May 20 '10 #1
0 1415

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7914
by: harry | last post by:
Hi, I have a program that runs on multiple client pc's. Occasionally one or more of those pc's use VPN to connect to another corporate network. When using VPN they need to set proxy server in Internet Explorer connection settings (proxy:8080). However, as soon as this setting is enabled, the remoting program running on their pc stops...
0
1130
by: Roshan Jayalath | last post by:
Hi all, Can someone tell me how to create the Pocket Internet explorer object and assign it into a variable so I can use it as a web browser control within a Vb.net form. SET loPIE = CREATEOBJECT(???) Best regards, Roshan Jayalath.
11
1753
by: dhplank | last post by:
Hello everyone, I've developed a calendar program in javascript, and up until now I've done most of my testing using Mozilla and Firefox. Everything works fine, but when I try to use Internet Explorer my response time is sometimes 50 times slower than using Mozilla. I know I haven't given you much to go by, but I'm not looking for an...
6
4582
by: tinkerman | last post by:
Hello net friends, I need to automate Internet Explorer in a very simple way. I need to: 1. press refresh (F5) on the currently loaded website. 2. press END button. 3. Click a button somewhere on the screen with the mouse left button (I'm not sure this button can be pressed directly via keysequence, not via mouse, but it does have a...
10
3153
by: Edlueze | last post by:
I am developing some Data Access Pages (DAP) using Microsoft Access 2003 on Microsoft Windows XP. When I try to open these pages (located on my C: drive), the display of the data access page is blocked and I receive the following error message in the Information Bar in Microsoft Internet Explorer: "To help protect your security, Internet...
7
2950
by: Stewart Saathoff | last post by:
Hello, Does anyone know how to open an Internet Explorer URL with a specified Path when someone clicks a URL?
16
5638
by: VBSome | last post by:
As far as I understand there is no native VB.NET equivalent of the VB6 Web browser control. There are some things I can play with HTML wise, but none do what I really need to do (which is ultimately walk the DOM & programatically click on elements in the DOM). I am trying to rebuild some of the stuff I've done in VB6 in dotnet by using the...
1
3500
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that products events which I want to consume (sink) within Internet Explorer. I'm following the instructions at:...
11
2011
by: GHUM | last post by:
Hello, I created some rather complex Intranet Application, using lots of JavaScript, DOM-Maninpulation and XMLHTTPRequest communication. I developed on FireFox, with the excellent firebug ... every misstake was given back with a fine, fine traceback; exactly pointing to the code at error. My code runs fine on FireFox and Opera.
26
2252
by: Prisoner at War | last post by:
Hi, All: I have a JavaScript search engine that always causes MSIE 7 to do a top-of-page security "warning" (that top-of-page-bar, and not an "alert" )...but other websites' JavaScripts do not trigger that...what's going on? When I visit other JavaScript sites there's no warning and the scripts work fine, but mine (it's still under...
0
7862
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7789
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7894
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8169
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5361
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3803
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1400
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.