Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default tmp files - so many tmp files!

Once our Excel spreadsheet is opened, between
3000 - 4000 tmp files are created in the
...\Local Settings\Temp directory.
The next time Excel is opened, it takes five minutes
for a(any) spreadsheet to load, effectively disabling
Excel.

How can I prevent these tmp files from being created?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default tmp files - so many tmp files!

Jumbo,

You can't stop them from being created but you can tidy them, up.Here is a
VBscript script that I use to do just that. I have a scheduled job that runs
every time I login which rujns this script.

This code empties the temp directory, but it could be amended for any
directory for files ending in .tmp. You're welcome to it. Just put it in a
..vbs file and either put it on the desktop or a desktop shortcut to it, and
launch it with a double-click. I run a scheduled job to launch it on startup

'---------------------------------------------------------------------------
' File: tempDirTidy
' Function: deletes inactive files from the Windows Temp directory
' i.e. files not automatically deleted by the creating process
'---------------------------------------------------------------------------

Const TemporaryFolder = 2 'for GetSpecialFolder

Set FSO = CreateObject("Scripting.FileSystemObject")

'init an empty array (UBound will be -1)...
'
'we use an array and store the file objects as this avoids any problems
' with altering the contents of the Files collections while they
' are being iterated.

arFiles = Array()
count = -1

'get the path to the temp folder
'
tempdir = FSO.GetSpecialFolder(TemporaryFolder)

'load the (global scope) array arFiles
'SelectFiles calls itself recursively for SubFolders

SelectFiles tempdir

'the error trap is in case any are in-use...

dCount = 0
For Each file In Arfiles
On Error Resume Next
file.Delete True
If Err.Number = 0 Then
dCount = dCount + 1
End If
Err.Clear
On Error Goto 0
Next

'now go back and delete empty folders below the temp folder

DeleteEmptyFolders tempdir,False

'comment out for "silent" operation,
' or add support for a "/s" command-line switch.

Msgbox count+1 & " files were found in " & tempdir & vbcrlf & dCount & " of
those files were deleted.", vbInformation,"Windows Temp Directory Tidy-up"


'---------------------------------------------------------------------------
Sub SelectFiles(sPath)
'---------------------------------------------------------------------------

'select files to delete and add to array...

Set Folder = FSO.Getfolder(sPath)
Set Files = Folder.Files

For Each file In Files
Count = Count + 1
Redim Preserve arFiles(Count)
Set arFiles(Count) = file
Next

For Each fldr In Folder.Subfolders
Selectfiles Fldr.Path
Next

End Sub


'---------------------------------------------------------------------------
Sub DeleteEmptyFolders(sPath,fDeleteThisFolder)
'---------------------------------------------------------------------------

Set Folder = FSO.GetFolder(sPath)

'recurse first...

For Each fldr In Folder.Subfolders
DeleteEmptyFolders fldr.Path,True
Next

'if no files or folders then delete...

'fDeleteThisFolder is False for the root of the subtree,
' and true for sub-folders (unless you want to delete
' the entire subtree if it is empty).

If (Folder.Files.Count = 0) And _
(Folder.Subfolders.Count) = 0 And _
fDeleteThisFolder Then
Folder.Delete
Exit Sub
End If

End Sub

'---------------------------------
end-script ---------------------------------

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jumbo Shrimps Jr." wrote in message
...
Once our Excel spreadsheet is opened, between
3000 - 4000 tmp files are created in the
..\Local Settings\Temp directory.
The next time Excel is opened, it takes five minutes
for a(any) spreadsheet to load, effectively disabling
Excel.

How can I prevent these tmp files from being created?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigating to Excel files over network slow, but not Word files Newbie123 Excel Discussion (Misc queries) 1 December 2nd 09 01:18 PM
How can I batch convert 97-2003 .xls files to 2007 .xlsx files Dave Nuttall Excel Discussion (Misc queries) 4 August 3rd 09 11:38 PM
Excel 2007 tmp files filling up drive with XLSM files Jim Excel Worksheet Functions 0 September 12th 08 03:31 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
converter tool to convert XL 2007 files to XL 2003 files Dave F Excel Discussion (Misc queries) 6 December 15th 06 12:45 AM


All times are GMT +1. The time now is 03:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"