Clearing Cache VBA

Dbarton0231

New Member
Joined
Mar 3, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
I have several workbooks that I update each morning and load to SharePoint for multiple users to view. Recently, there has been an issue with the workbooks not displaying the updates that were loaded. Having the user clear their cache resolves the issue. My question is, is there any VBA that can run upon opening the workbook that will automatically clear the users cache? Or at the very least some VBA that can be executed on demand by the user if they are not seeing updated information in the workbooks?
 

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.
The only thing that come to my mind is clearing all the variable whose scope extends outside a specific macro; this includes those variables that are declared on top of vba modules, before any Sub or Function
To clear a variable:
VBA Code:
VarName = Empty

Let's see if someone else has more insights

Bye
 
Upvote 0
To clear brouser's cache try this code before downloading workbook from SharePoint site:
VBA Code:
Sub ClearCache()
  CreateObject("wscript.shell").Run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255", 0, True
End Sub
 
Upvote 0
That is interesting on clearing the brouser's cache.

Is there a vba way to delete cached files?


Untitled .png
 
Upvote 0
I have several workbooks that I update each morning and load to SharePoint for multiple users to view. Recently, there has been an issue with the workbooks not displaying the updates that were loaded. Having the user clear their cache resolves the issue. My question is, is there any VBA that can run upon opening the workbook that will automatically clear the users cache? Or at the very least some VBA that can be executed on demand by the user if they are not seeing updated information in the workbooks?
Hello,

How did you solve this problem? I have the same situation and I can only solve it, deleting the cached files manually. Is there any VBA code to do it automatically?

Thank you
 
Upvote 0
Hello,

How did you solve this problem? I have the same situation and I can only solve it, deleting the cached files manually. Is there any VBA code to do it automatically?

Thank you
I used the following to clear cookies and temporary internet files:

VBA Code:
Sub Cache()
    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 2"
    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 8"
   
End Sub

In addition, below are several options that can used:

VBA Code:
Delete Temporary Internet Files:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Delete Cookies:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete History:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Form Data:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete Passwords:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All + files and settings stored by Add-ons:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
 
Upvote 0
I used the following to clear cookies and temporary internet files:

VBA Code:
Sub Cache()
    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 2"
    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 8"
  
End Sub

In addition, below are several options that can used:

VBA Code:
Delete Temporary Internet Files:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8

Delete Cookies:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Delete History:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1

Delete Form Data:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16

Delete Passwords:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32

Delete All:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

Delete All + files and settings stored by Add-ons:
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
Hello,

I've tried all solutions but nothing works.
Also tried the following code:

Sub DeleteCachedFiles()
Dim folderPath As String
folderPath = Environ("LOCALAPPDATA") & "\Microsoft\Office\16.0\OfficeFileCache"

On Error Resume Next
Kill folderPath & "\*.*"
On Error GoTo 0

MsgBox "Cached files deleted successfully!", vbInformation
End Sub

But if I delete manually the folder C:\Users\####\AppData\Local\Microsoft\Office\16.0\OfficeFileCache it solve the problem.

Thanks for the help.
 
Upvote 0
Good Day don0231,

Just wanted to inform that the code worked on my end and appreciate all of the "extras".

VBA Code:
Sub ClearCached()
'
Application.ScreenUpdating = False

    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 2"
    'Browsing_History
    Shell "RunDll32.exe InetCpl.Cpl, ClearMyTracksByProcess 8"

originalSetting = Application.RecentFiles.Maximum

Application.RecentFiles.Maximum = 0

Application.RecentFiles.Maximum = originalSetting
 
End Sub

R/
pinaceous
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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