There is a way to clear the local project cache from Project VBA. You need to create a windows batch file to delete the file "C:\Documents and Settings\"%username%"\Application Data\Microsoft\MS Project\Cache". When run the batch file is run from MS Project it will delete all files and folders which are not currently in use by the application (it's pretty much doing the same thing the Cleanup Cache feature does). When the batch file is run when the application is closed it will delete the entire cache folder.
Code:
Sub ClearCache()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
'String for creation of batch file
sFile = "C:\Clear Cache.bat"
'Text to put in batch file to delete
'local cache for any user
sText = "rd /s/q " & Chr(34) & "C:\Documents " _
& "and Settings\" & Chr(34) & "%username%" _
& Chr(34) & "\Application Data\Microsoft\" _
& "MS Project\Cache" & Chr(34)
'create and close .bat file
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
'run .bat file to clear cache
Dim ret As Integer
ret = Shell("C:\Clear Cache.bat")
End Sub
Peter Schneider wrote:
Clear Local Project Cache Programmatically
27-May-09
Hi!
Has anyone a clue how to clear the local project cache automatically via
code.
I've only found the method object model projectApp.CleanupCache()
which just displays the dialog box.
greetings, Peter Schneider
Previous Posts In This Thread:
Clear Local Project Cache Programmatically
Hi!
Has anyone a clue how to clear the local project cache automatically via
code.
I've only found the method object model projectApp.CleanupCache()
which just displays the dialog box.
greetings, Peter Schneider
Re: Clear Local Project Cache Programmatically
Try recording a macro of you dong this. What gets recorded is what's
available.
--
Rod Gill
Microsoft MVP for Project
Author of the only book on Project VBA, see:
http://www.projectvbabook.com
Re: Clear Local Project Cache Programmatically
Hi Rod!
It records just the method CleanupCache(), which is displayed as a modal
dialog. ;-/
Right at the moment i try another way, by just deleting the files directly
under Document and Settings\User\App Data...
I am aware that I could loose data by doing this. ;(
greetings, Peter
"Rod Gill" <rodATproject-systemsDOTcoDOTnz> schrieb im Newsbeitrag
Re: Clear Local Project Cache Programmatically
Peter:
You can accomplish this using a simple .bat file to delete the cache. The
question is, when do you want to do this? Whether you use the method or the
deletion approach, you run the risk of losing data that isn't saved to the
draft folder which is difficult to imagine inasmuch as Project prompts the
user to save unsaved data when they attempt to close a project or the
application itself. Further, the system will not allow you to delete the
cache if Project is open and the cache is engaged.
Clear Project Cache Programatically
There is a way to clear the local project cache from Project VBA. You need to create a windows batch file to delete the file "C:\Documents and Settings\"%username%"\Application Data\Microsoft\MS Project\Cache". When run the batch file is run from MS Project it will delete all files and folders which are not currently in use by the application (it's pretty much doing the same thing the Cleanup Cache feature does). When the batch file is run when the application is closed it will delete the entire cache folder.
Code:
Sub ClearCache()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
'String for creation of batch file
sFile = "C:\Clear Cache.bat"
'Text to put in batch file to delete
'local cache for any user
sText = "rd /s/q " & Chr(34) & "C:\Documents " _
& "and Settings\" & Chr(34) & "%username%" _
& Chr(34) & "\Application Data\Microsoft\" _
& "MS Project\Cache" & Chr(34)
'create and close .bat file
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
'run .bat file to clear cache
Dim ret As Integer
ret = Shell("C:\Clear Cache.bat")
End Sub
Clear Local Project Cache Programmatically
There is a way to clear the local project cache from Project VBA. You need to create a windows batch file to delete the file "C:\Documents and Settings\"%username%"\Application Data\Microsoft\MS Project\Cache". When run the batch file is run from MS Project it will delete all files and folders which are not currently in use by the application (it's pretty much doing the same thing the Cleanup Cache feature does). When the batch file is run when the application is closed it will delete the entire cache folder.
Code:
Sub ClearCache()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
'String for creation of batch file
sFile = "C:\Clear Cache.bat"
'Text to put in batch file to delete
'local cache for any user
sText = "rd /s/q " & Chr(34) & "C:\Documents " _
& "and Settings\" & Chr(34) & "%username%" _
& Chr(34) & "\Application Data\Microsoft\" _
& "MS Project\Cache" & Chr(34)
'create and close .bat file
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
'run .bat file to clear cache
Dim ret As Integer
ret = Shell("C:\Clear Cache.bat")
End Sub
Clear Local Project Cache Programmatically
There is a way to clear the local project cache from Project VBA. You need to create a windows batch file to delete the file "C:\Documents and Settings\"%username%"\Application Data\Microsoft\MS Project\Cache". When run the batch file is run from MS Project it will delete all files and folders which are not currently in use by the application (it's pretty much doing the same thing the Cleanup Cache feature does). When the batch file is run when the application is closed it will delete the entire cache folder.
Code:
Sub ClearCache()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
'String for creation of batch file
sFile = "C:\Clear Cache.bat"
'Text to put in batch file to delete
'local cache for any user
sText = "rd /s/q " & Chr(34) & "C:\Documents " _
& "and Settings\" & Chr(34) & "%username%" _
& Chr(34) & "\Application Data\Microsoft\" _
& "MS Project\Cache" & Chr(34)
'create and close .bat file
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
'run .bat file to clear cache
Dim ret As Integer
ret = Shell("C:\Clear Cache.bat")
End Sub
EggHeadCafe - Software Developer Portal of Choice
SQL Server - UDF for Business Days Calculation
http://www.eggheadcafe.com/tutorial...bc-ffd2a06bb67e/sql-server--udf-for-busi.aspx