Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 26
Default Directory Printer

Does anyone have a ready-made FORM (or code only) for printing the content
(FileName, Date, Time, size) of a directory. I found this neat application
(freeware) on http://www.spadixbd.com/freetools/ but I am looking for
something to incorporate an EXCEL program.

Reagrds

Michel


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Directory Printer

I did the project with code below for someone just interested in the file
names and date information but it should be very simple to add file size or
other parameters you might want...Steve

First Create a reference to "Microsoft Scripting Runtime" (Tools
References) in VBE.

In module 1:

Sub DoNewFolder()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub


Sub ListFilesInFolder(SourceFolderName As String, AlsoSubfolders As Boolean)
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = " "
Cells(r, 2).Formula = FileItem.Name
Cells(r, 3).Formula = FileItem.DateCreated
Cells(r, 4).Formula = FileItem.DateLastModified
Cells(r, 5).Formula = FileItem.DateLastAccessed
r = r + 1
Next FileItem
If AlsoSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
r = Range("A65536").End(xlUp).Row + 1
Cells(r, 1).Formula = SubFolder.Path
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
End Sub


Under "ThisWorkbook":

Private Sub Workbook_Open()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub



"MD" wrote in message
...
Does anyone have a ready-made FORM (or code only) for printing the content
(FileName, Date, Time, size) of a directory. I found this neat

application
(freeware) on http://www.spadixbd.com/freetools/ but I am looking for
something to incorporate an EXCEL program.

Reagrds

Michel




  #3   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 26
Default Directory Printer

Well done Steve.... That will give me a head start!

Michel


"Steve Yandl" a écrit dans le message de
...
I did the project with code below for someone just interested in the file
names and date information but it should be very simple to add file size

or
other parameters you might want...Steve

First Create a reference to "Microsoft Scripting Runtime" (Tools
References) in VBE.

In module 1:

Sub DoNewFolder()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub


Sub ListFilesInFolder(SourceFolderName As String, AlsoSubfolders As

Boolean)
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = " "
Cells(r, 2).Formula = FileItem.Name
Cells(r, 3).Formula = FileItem.DateCreated
Cells(r, 4).Formula = FileItem.DateLastModified
Cells(r, 5).Formula = FileItem.DateLastAccessed
r = r + 1
Next FileItem
If AlsoSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
r = Range("A65536").End(xlUp).Row + 1
Cells(r, 1).Formula = SubFolder.Path
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
End Sub


Under "ThisWorkbook":

Private Sub Workbook_Open()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub



"MD" wrote in message
...
Does anyone have a ready-made FORM (or code only) for printing the

content
(FileName, Date, Time, size) of a directory. I found this neat

application
(freeware) on http://www.spadixbd.com/freetools/ but I am looking for
something to incorporate an EXCEL program.

Reagrds

Michel






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Directory Printer


Hi,

I've yet to try the code, but am looking for something, which I'm not
sure if this thread addressed.

I would like to have an Excel ss file list for me, in separate
columns, all my files, in certain directories, giving all information
like file size, date, etc.

1 column = 1 certain directory.
4 or 5 rows in that column to spec the listed file (file size, date,
etc).

Thanks,
George



On Wed, 25 Aug 2004 16:30:57 -0400, "MD"
wrote:

Well done Steve.... That will give me a head start!

Michel


"Steve Yandl" a écrit dans le message de
...
I did the project with code below for someone just interested in the file
names and date information but it should be very simple to add file size

or
other parameters you might want...Steve

First Create a reference to "Microsoft Scripting Runtime" (Tools
References) in VBE.

In module 1:

Sub DoNewFolder()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub


Sub ListFilesInFolder(SourceFolderName As String, AlsoSubfolders As

Boolean)
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = " "
Cells(r, 2).Formula = FileItem.Name
Cells(r, 3).Formula = FileItem.DateCreated
Cells(r, 4).Formula = FileItem.DateLastModified
Cells(r, 5).Formula = FileItem.DateLastAccessed
r = r + 1
Next FileItem
If AlsoSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
r = Range("A65536").End(xlUp).Row + 1
Cells(r, 1).Formula = SubFolder.Path
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
End Sub


Under "ThisWorkbook":

Private Sub Workbook_Open()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub



"MD" wrote in message
...
Does anyone have a ready-made FORM (or code only) for printing the

content
(FileName, Date, Time, size) of a directory. I found this neat

application
(freeware) on http://www.spadixbd.com/freetools/ but I am looking for
something to incorporate an EXCEL program.

Reagrds

Michel






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Directory Printer

George

Several methods to accomplish this.......I like Tushar's best.

To add a "Print Directory" feature to Explorer, go to
this KB Article.

http://support.microsoft.com/default...EN-US;q272623&

Or you can download Printfolder 1.2 from.....

http://no-nonsense-software.com/freeware/

I use PF 1.2 and find it to be more than adequate with custom features.

OR Go to DOS(Command) prompt and directory.
Type DIR MYFILES.TXT

All the above create a *.TXT file which can be opened in Excel.

One more method if you want to by-pass the *.TXT file and pull directly to
Excel is to use Tushar Mehta's Excel Add-in. This allows filtering and
sorting once you have the data in Excel.

http://www.tushar-mehta.com/ scroll down to Add-insDirectory Listing.

Download the ZIP file and un-zip to your Office\Library folder.

Gord Dibben Excel MVP

On Sat, 28 Aug 2004 15:15:13 GMT, George wrote:


Hi,

I've yet to try the code, but am looking for something, which I'm not
sure if this thread addressed.

I would like to have an Excel ss file list for me, in separate
columns, all my files, in certain directories, giving all information
like file size, date, etc.

1 column = 1 certain directory.
4 or 5 rows in that column to spec the listed file (file size, date,
etc).

Thanks,
George



On Wed, 25 Aug 2004 16:30:57 -0400, "MD"
wrote:

Well done Steve.... That will give me a head start!

Michel


"Steve Yandl" a écrit dans le message de
...
I did the project with code below for someone just interested in the file
names and date information but it should be very simple to add file size

or
other parameters you might want...Steve

First Create a reference to "Microsoft Scripting Runtime" (Tools
References) in VBE.

In module 1:

Sub DoNewFolder()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub


Sub ListFilesInFolder(SourceFolderName As String, AlsoSubfolders As

Boolean)
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim FileItem As Scripting.File
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
r = Range("A65536").End(xlUp).Row + 1
For Each FileItem In SourceFolder.Files
Cells(r, 1).Formula = " "
Cells(r, 2).Formula = FileItem.Name
Cells(r, 3).Formula = FileItem.DateCreated
Cells(r, 4).Formula = FileItem.DateLastModified
Cells(r, 5).Formula = FileItem.DateLastAccessed
r = r + 1
Next FileItem
If AlsoSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
r = Range("A65536").End(xlUp).Row + 1
Cells(r, 1).Formula = SubFolder.Path
ListFilesInFolder SubFolder.Path, True
Next SubFolder
End If
Columns("B:E").AutoFit
Set FileItem = Nothing
Set SourceFolder = Nothing
Set FSO = Nothing
End Sub


Under "ThisWorkbook":

Private Sub Workbook_Open()
Workbooks.Add
Dim fd As FileDialog
Dim strPath As String
Dim B As Integer
Dim IncludeSubfolders As Boolean
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
Dim selFldr As Variant
With fd
If .Show = -1 Then
For Each selFldr In .SelectedItems
strPath = selFldr & "\"
Next selFldr
Else
End If
End With
IncludeSubfolders = False
B = MsgBox("Include Subfolders?", vbYesNo, "Scope")
If B = 6 Then
IncludeSubfolders = True
Else
IncludeSubfolders = False
End If

With Range("A1")
.Formula = "Folder Contents: " & strPath
.Font.Bold = True
.Font.Size = 12
End With
Range("A3").Formula = " "
Range("B3").Formula = "File Name"
Range("C3").Formula = "Date Created"
Range("D3").Formula = "Date Last Modified"
Range("E3").Formula = "Date Last Accessed"
Range("A3:E3").Font.Bold = True
ListFilesInFolder strPath, IncludeSubfolders
Range("A2").Select
End Sub



"MD" wrote in message
...
Does anyone have a ready-made FORM (or code only) for printing the

content
(FileName, Date, Time, size) of a directory. I found this neat
application
(freeware) on http://www.spadixbd.com/freetools/ but I am looking for
something to incorporate an EXCEL program.

Reagrds

Michel








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Directory Printer

George,

Or you may want to give my "List Files" add-in a try.
You get the option to determine the type of files you want to list.
In addition, the file names are hyperlinked.
(includes button to remove all hyperlinks)
Free upon direct request - remove xxx from my email address.

Regards,
Jim Cone
San Francisco, CA
XX

"George" wrote in message ...
Hi,
I've yet to try the code, but am looking for something, which I'm not
sure if this thread addressed.
I would like to have an Excel ss file list for me, in separate
columns, all my files, in certain directories, giving all information
like file size, date, etc.
1 column = 1 certain directory.
4 or 5 rows in that column to spec the listed file (file size, date, etc).
Thanks,
George


- snip -
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
Printer Rey Excel Discussion (Misc queries) 3 October 23rd 07 09:02 PM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Printer Multiple Worksheets with a particular Printer Setting PP[_2_] Excel Worksheet Functions 0 March 14th 07 02:02 PM
Printer Set Up in VBA PostalVote Excel Programming 3 July 29th 04 12:29 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 04:25 PM.

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"