clear excel cache -- or maybe something else?

inosent

Board Regular
Joined
Mar 19, 2007
Messages
131
i have a routine that goes to a web site and gets data. the data at the site changes often.

but there is a quirk.

in order to get the most recent data, i *always* have to quit excel completely, and then restart, re-run the routine to get the most recent data

i have manually cleared the cache and the cookies but i still get the same issue.

i have tried adding CInt(1000 * Rnd()) to the link to try and force the cache (or whatever is causing the trouble) to see the link as a new link to force it to give up the old data and bring in the new

but nothing works.

once i open excel, and get the data, i will not be able to get new data from the site

i am using

Code:
Dim objHTTP As Object
Set objHTTP = CreateObject("MSXML2.XMLHTTP")


objHTTP.Open "GET", [the link], false
objHTTP.send 


set objHTTP = Nothing

to get the data

is there some code that will emulate excel shutting down or something? somehow, somewhere excel is 'holing on' to something in re this particular site, or something like that.

all i know is the only way to fix the problem, to update and get the new data, i always have to close excel and then restart, which of course is a pain

any ideas ?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Does the advice given in the Excel Help not assist?

  1. Click a cell in the region of the worksheet where your query data was returned (also known as an external data range.
  1. Click Refresh Data
    default.aspx
    on the External Data toolbar.
  2. A spinning refresh icon
    default.aspx
    appears in the status bar to indicate that the query is running. Double-click the icon to check the status of the query.
  3. Tips
  1. You can have your data refresh automatically when the file is opened, at timed intervals, or in the background by clicking Data Range Properties
    default.aspx
    on the External Data toolbar and selecting or clearing options under Refresh control.
    • If the data returned to your worksheet after a refresh isn't what you expected, check the Web page you are querying to make sure it is in the same location and that the data on it is provided in the same way as when you created the query.
 
Upvote 0
Noticed just as I hit return that you're using xml.

Does the Excel Help not assist then...


<TABLE class=OTbl cellSpacing=0 cellPadding=0 width="100%"><TBODY><TR><TD class=cdOTATtl width="100%">Refresh XML data </TD><TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 12px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px"></TD><TR><TD class=ACB style="PADDING-RIGHT: 12px; PADDING-LEFT: 12px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px" width="100%" colSpan=3><!-- defs in --><!-- META NAME="lcid" CONTENT="1033" -->Note XML features, except for saving files in the XML Spreadsheet format, are available only in Microsoft Office Professional Edition 2003 and Microsoft Office Excel 2003.

  • Click Refresh XML Data
    default.aspx
    on the XML toolbar to import the latest data from the data source.
</TD></TR></TBODY></TABLE>
of course, assuming your using 2003 or later version...
 
Upvote 0
thanks for the reply

well, basically nothing is being saved to the spreadsheet. objHTTP.responseText is processed independently of the spreadsheet, and the data is saved to a text file.

the problem i am having is after hitting [the link] the first time around, and i get the data, as long as i have that instance of excel open the .responseText from the same link will say no new data when in fact there is

so this has nothing to do with the spreadsheet, excel is more of an after thought. but somehow there is some diabolical cache thing going on because the link with the site is still active or something, i really cant say

i've used Set objHTTP = Nothing but that doesnt work either

i guess the question is in what way does excel hold its own cache (if that is the issue)? why is it, in order to establish a current connection to the site, why do i always have to shut excel down completely?
 
Upvote 0
for posterity, i solved this issue by using code to 1) clear the cache and 2) beefed up the logging out from the site. the issue was not 'technically' with excel, but at the site. however, the question of how to break a connection with a site w/o having to necessarily log off at the site, emuilating the quitting of excel and restartgin excel is still a mystery.

there is likely some sort of 'excel cache' somewhere, otherwise the site would not think the 'browser' session had ended when excel quit.

iow, excel in this case acts as a browser, storing a cookie somewhere, keeping the session between the site and excel active so long as excel is open.

once excel quits, the link with the site is severed, and the mystery cookie (wherever it is) gets killed

this question still has not been resolved
 
Upvote 0
inosent,

Have you deleted the querytables and Workbook connections?

for Query Tables:
Code:
For Each x In Worksheets(wsTemp).QueryTables
        x.Delete
Next

For Connections:
Code:
For Each x In ThisWorkbook.Connections
        x.Delete
Next

Can you post your code for deleting the cache? I'd love to see how you did it.

Thanks!
 
Upvote 0
I know this is an old thread, but I struggled through this issue earlier in the week. The solution I found was to change xmlhttp to serverxmlhttp. Apparently, one of the benefits of xmlhttp is the caching. May not be the best , but it fixes the problem without have to deal with random strings and headers.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top