Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Kill Function by author

Hi.

I'm handing back my laptop to a company having worked on secondment for them
for a year. In this time I've created hundreds of excel files that sit
mingled with 100's from the company. They have no designated home and sit
randomly across the hard drive. Basically, I want to delete all of the files
that I created and leave the files behind that are generic to the company. I
know the kill function can work on set locations, but is there a way to
delete files based on the value in the author/properties field? sounds tricky.

THanks in advance of a seriously clever answer!

GC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Kill Function by author

This function can get the uthor property of an open workbook, which you can
then use the path of to kill


'-----------------------------------------------------------------
Function DocProps(prop As String)
'-----------------------------------------------------------------
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


use as

If DocProps("author") = "me" Then

Kill Activeworkbook.Fullname
ActiveWorkbook.Close SaveChanges:=False
End If

--
__________________________________
HTH

Bob

"Gordon" wrote in message
...
Hi.

I'm handing back my laptop to a company having worked on secondment for
them
for a year. In this time I've created hundreds of excel files that sit
mingled with 100's from the company. They have no designated home and sit
randomly across the hard drive. Basically, I want to delete all of the
files
that I created and leave the files behind that are generic to the company.
I
know the kill function can work on set locations, but is there a way to
delete files based on the value in the author/properties field? sounds
tricky.

THanks in advance of a seriously clever answer!

GC



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Kill Function by author

Hi Bob...

If my user name is say Boffin, can you package that code so that I can just
run it once from an excel sheet and all excel files with the author name
Boffin are deleted on my laptop, regardless of location or path?

Thanks so far... we're getting there.

Cheers


"Bob Phillips" wrote:

This function can get the uthor property of an open workbook, which you can
then use the path of to kill


'-----------------------------------------------------------------
Function DocProps(prop As String)
'-----------------------------------------------------------------
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


use as

If DocProps("author") = "me" Then

Kill Activeworkbook.Fullname
ActiveWorkbook.Close SaveChanges:=False
End If

--
__________________________________
HTH

Bob

"Gordon" wrote in message
...
Hi.

I'm handing back my laptop to a company having worked on secondment for
them
for a year. In this time I've created hundreds of excel files that sit
mingled with 100's from the company. They have no designated home and sit
randomly across the hard drive. Basically, I want to delete all of the
files
that I created and leave the files behind that are generic to the company.
I
know the kill function can work on set locations, but is there a way to
delete files based on the value in the author/properties field? sounds
tricky.

THanks in advance of a seriously clever answer!

GC




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Kill Function by author

I would think this will be incredibly slow, going through every file on the
system

Dim oFSO

Sub LoopFolders()

Set oFSO = CreateObject("Scripting.FileSystemObject")

selectFiles "c:\"

Set oFSO = Nothing

End Sub


'---------------------------------------------------------------------------
Sub selectFiles(sPath)
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = oFSO.GetFolder(sPath)

If Folder.Name = "Windows" Then Exit Sub
On Error GoTo exit_sub
For Each fldr In Folder.Subfolders

selectFiles fldr.Path
Next fldr

On Error GoTo 0
For Each file In Folder.Files

If file.Type Like "*Microsoft*Excel*Worksheet*" Then

Workbooks.Open Filename:=file.Path
If DocProps("author") = "Boffin" Then

Kill ActiveWorkbook.FullName
End If
ActiveWorkbook.Close SaveChanges:=False
End If
Next file
exit_sub:
End Sub


'-----------------------------------------------------------------
Function DocProps(prop As String)
'-----------------------------------------------------------------
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function




--
__________________________________
HTH

Bob

"Gordon" wrote in message
...
Hi Bob...

If my user name is say Boffin, can you package that code so that I can
just
run it once from an excel sheet and all excel files with the author name
Boffin are deleted on my laptop, regardless of location or path?

Thanks so far... we're getting there.

Cheers


"Bob Phillips" wrote:

This function can get the uthor property of an open workbook, which you
can
then use the path of to kill


'-----------------------------------------------------------------
Function DocProps(prop As String)
'-----------------------------------------------------------------
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


use as

If DocProps("author") = "me" Then

Kill Activeworkbook.Fullname
ActiveWorkbook.Close SaveChanges:=False
End If

--
__________________________________
HTH

Bob

"Gordon" wrote in message
...
Hi.

I'm handing back my laptop to a company having worked on secondment for
them
for a year. In this time I've created hundreds of excel files that sit
mingled with 100's from the company. They have no designated home and
sit
randomly across the hard drive. Basically, I want to delete all of the
files
that I created and leave the files behind that are generic to the
company.
I
know the kill function can work on set locations, but is there a way to
delete files based on the value in the author/properties field? sounds
tricky.

THanks in advance of a seriously clever answer!

GC






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
Set author for a comment? Myles Excel Discussion (Misc queries) 5 March 30th 09 07:09 PM
how to change Author name Author name Excel Discussion (Misc queries) 2 April 29th 08 10:07 AM
Kill Function AJM1949 Excel Programming 3 April 19th 07 05:32 AM
print author jiwolf Excel Worksheet Functions 1 March 15th 06 08:28 PM
How to Kill a vba macro from a Function// coco Excel Programming 4 June 24th 05 11:11 PM


All times are GMT +1. The time now is 02:31 PM.

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

About Us

"It's about Microsoft Excel"