|
-
Jul 20th, 2004, 05:27 PM
#1
Thread Starter
Lively Member
Excel 97 VBA - File Control
Question:
I am trying to delete several files from my system. This is code to be included with my program upgrade. We have several directories with pictures that are no longer used.
I can code to remove the files. I can code to delete the directories. This is done from within Excel 97 VBA.
I am getting errors due to the thumbs.dat file. Excel VBA does not seem to see this file in order to delete it. Consequently, I am left with an empty directory structure, each with their own thumbs.dat file.
Is there code that I am missing that would delete an entire directory including the thumbs.dat file that may reside in it.
Thanks
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 21st, 2004, 03:03 AM
#2
Addicted Member
Cannot delete a folder until it is empty (use RmDir).
should delete all files in a folder.
Regards
BrianB
-------------------------------
-
Jul 24th, 2004, 01:46 PM
#3
Thread Starter
Lively Member
should, but doesn't. thumds.db does not seem affected by this command.
It doesn't even come up with a DIR command.
And if I can't delete the file, then I can't delete the directory since it's not empty.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 25th, 2004, 10:22 AM
#4
What OS is this? What program created all the thumbs.db files? The OS or some picture program. You might try looking at killing some kind of service.
-
Jul 25th, 2004, 05:54 PM
#5
Thread Starter
Lively Member
thumbs.db is a system created file in windows XP.
I can delete it via the Windows Explorer or My Computer.
A DOS prompt, can't see it or delete it.
ANd I have yet to figure out how to get VBA to see it and delete it.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 25th, 2004, 06:14 PM
#6
Try the ATTRIB command. I don't see any such file on my XP system, but I didnt look all over.
Use it like this:
ATTRIB *.* to show all the files from a command shell.
ATTRIB -s thumbs.db to remove the system property.
ATTRIB -h thumbs.db to remove the hidden attribute.
ATTRIB -r thumbs.db to remove the read-only attribute.
or,
ATTRIB -s -h -r thumbs.db to do it all at once. That may get you started in the right direction.
-
Jul 25th, 2004, 06:15 PM
#7
Oh ya, after all that you can delete the file
-
Jul 25th, 2004, 09:05 PM
#8
Thread Starter
Lively Member
Tried this with no result.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 26th, 2004, 12:04 AM
#9
it must NOT be opened to delete it
-
Jul 26th, 2004, 07:11 AM
#10
I agree there must be a program or service running that has the file(s) open.
I don't see that file on my other XP system either. Check for some graphical software running. Kill everything. Something has that file locked.
-
Jul 26th, 2004, 05:46 PM
#11
Thread Starter
Lively Member
You're missing the point.
thumbs.db is a windows XP system created file.
IT's part of an Advanced Folder Setting: Do you want to cache thumbnails?
The file is self re-creating, meaning, it will replace itself each time a picture directory is opened within Windows XP. The file stores the thumbnail information for your user account and the directory you are looking at.
I am installing software on other people
s computer. I have no way of knowing if this file exists, but it is preventing me from deleting and changing my own directory structure. My software has two folders with graphics, so the user's computer, depending on the settings, may create this file for them.
I am not sure if there is any a process to kill. All I know is that I can see the file in Windows Explorer but not via code.
Are you sure it's not on you WIn XP system?
Click on my pictures, choose a folder with pics, and then under folder option, Show Protected Operating System Files.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 26th, 2004, 05:57 PM
#12
Indeed you are correct, I found it under "My Pictures", but I was able to delete it via a command shell using ATTRIB and then DEL.
After that the file was gone.
I spose after the system reboots the file will return, but you should be able to delete the folder before that happens.
-
Jul 26th, 2004, 08:06 PM
#13
Thread Starter
Lively Member
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 26th, 2004, 08:23 PM
#14
I suppose with the Shell command you can do it. Need help with that?
-
Jul 26th, 2004, 08:25 PM
#15
Thread Starter
Lively Member
Yep since I'm curious as to how different you code it from what I would do.
-----
#VBA, VB 6 Professional Edition, Office XP Developper. Excel 97, Excel 2000, Excel XP
I miss my VIC 20.
Never should have upgraded to my commodore 64. ...
-
Jul 27th, 2004, 03:33 AM
#16
Haven't tried this but:
VB Code:
public sub testforfile()
dim strFile as string, strPath as string
strPath="C:\testfolder"
strfile = dir$(strpath & "\*.*",63)
do until len(Strfile)=0
debug.print strfile
strfile=dir$
loop
I can't test here (win2k) but that 'should' return all the files/folders in the directory. Its the 63 bit that I always put in 
Lemme know if it works or not 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 27th, 2004, 07:14 AM
#17
Originally posted by TheFIDDLER
Yep since I'm curious as to how different you code it from what I would do.
Code:
Shell "C:\Windows\system32\attrib -s -h -r ""C:\Documents and Settings\username\My Documents\My Pictures\thumbs.db"""
Shell "cmd.exe /c DEL ""C:\Documents and Settings\username\My Documents\My Pictures\thumbs.db"""
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|