VBA to Clear Cache in Excel

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Good Day All,

Is there a vba macro to clear cache in excel?

For example as in;

Clear Cache in Excel

Please let me know!

Thank you!
pinaceous
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I saw this on the web. Is it what you're looking for?
VBA Code:
Application.RecentFiles.Maximum = 0
Hey *Skyybot!

I believe so but how can I tell that it worked?

Thanks,
pinaceous
 
Upvote 0
I use office 2016 which doesn't have the "Delete cached files" entry under Options|Save menu so I can't give this shot but I think the best way to programmatically press that button is via Microsoft Active Accessibility.

Also, there might be a flag entry in the registry which may enable you to delete the cached files. Have you considered looking there ?
 
Upvote 0
Hey *Skyybot!

I believe so but how can I tell that it worked?

Thanks,
pinaceous
As far as I can tell, if the file C:\Users\"UserName"\AppData\Local\Microsoft\Office\16\OfficeFileCache contains a file named "0" then the cache is clear. I have seen posts on other forums suggesting deleting that file (OfficeFileCache) but I think that is used for other Office apps as well and I'm unsure of how that will affect operation of other Office apps.
 
Upvote 0
It does actually but I had to use a button click in referring the macro on the main excel page not the vba page.

Can you provide a link to a workbook with the code you mentioned that gets you to the window you displayed?
 
Upvote 0
Can you provide a link to a workbook with the code you mentioned that gets you to the window you displayed?
I'm having trouble with how to create a link for the workbook. Just create any new.xlsm as below with the button click and reference the macro 4 as above for it and it will work.
Captureddd.PNG
 
Upvote 0
I use office 2016 which doesn't have the "Delete cached files" entry under Options|Save menu so I can't give this shot but I think the best way to programmatically press that button is via Microsoft Active Accessibility.

Also, there might be a flag entry in the registry which may enable you to delete the cached files. Have you considered looking there ?
Hi Jaafar Tribak,

Do you know how to access the flag entry in the registry through vba?

Thanks,
pinaceous
 
Upvote 0
I'm having trouble with how to create a link for the workbook. Just create any new.xlsm as below with the button click and reference the macro 4 as above for it and it will work.
View attachment 86211

You could upload it to any free file sharing site. I usually use This but you can use dropbox or any of your choice. Then supply the link to the file here.

Edit: I finally got it to work with the code you provided.
 
Last edited:
Upvote 0
Ok the following code should take you right up to the edge:

VBA Code:
    SendKeys "%"
    SendKeys "FT^S%D%D~{TAB}"

The following code would take you to the edge & actually pull the trigger:

VBA Code:
    SendKeys "%"
    SendKeys "FT^S%D%D~{TAB}~"


You probably should add a final line to turn the num lock back on:
VBA Code:
    SendKeys "{NUMLOCK}", True
 
Last edited:
Upvote 0
You could upload it to any free file sharing site. I usually use This but you can use dropbox or any of your choice. Then supply the link to the file here.

Edit: I finally got it to work with the code you provided.
Hi johnnyL,
I'll work on that and let you know.
Thank you,
pinaceous
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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