[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Paste filenames into cells

Akash

12/15/2006 5:24:00 AM

Dear Don,
I was going through the earlier one of your mail on 14th Dec regarding
Paste filenames into cells

there u have given a code

Sub GetFileList()
Dim iCtr As Integer

With Application.FileSearch
.NewSearch
.LookIn = "c:\aa"
.SearchSubFolders = True
.Filename = ".xls"
If .Execute > 0 Then
For iCtr = 1 To .FoundFiles.Count
Cells(iCtr, 1).Value = .FoundFiles(iCtr)
Next iCtr
End If
End With
End Sub
=====
or DIR

Sub anotherfindfiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim MediaFileLocation As String
MediaFileLocation = "c:\yourfolder\*.xls"
FN = Dir(MediaFileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub

I am not able to execute it. Or u can say i m not able understand how
the macro works.
How the user can select files from a single folder. Instead of opening
them.

Awaiting for ur mail...

Regards

Akash

2 Answers

Don Guillett

12/15/2006 1:14:00 PM

0

The original post said to make a list on a worksheet. It should be fairly
self explanatory. Just change the path to your folder/directory.

--
Don Guillett
SalesAid Software
dguillett1@austin.rr.com
"Akash" <maheshwari.akash@gmail.com> wrote in message
news:1166160247.268996.297280@f1g2000cwa.googlegroups.com...
> Dear Don,
> I was going through the earlier one of your mail on 14th Dec regarding
> Paste filenames into cells
>
> there u have given a code
>
> Sub GetFileList()
> Dim iCtr As Integer
>
> With Application.FileSearch
> .NewSearch
> .LookIn = "c:\aa"
> .SearchSubFolders = True
> .Filename = ".xls"
> If .Execute > 0 Then
> For iCtr = 1 To .FoundFiles.Count
> Cells(iCtr, 1).Value = .FoundFiles(iCtr)
> Next iCtr
> End If
> End With
> End Sub
> =====
> or DIR
>
> Sub anotherfindfiles()
> Application.ScreenUpdating = False
> Dim FN As String ' For File Name
> Dim ThisRow As Long
> Dim MediaFileLocation As String
> MediaFileLocation = "c:\yourfolder\*.xls"
> FN = Dir(MediaFileLocation)
> Do Until FN = ""
> ThisRow = ThisRow + 1
> Cells(ThisRow, 1) = FN
> FN = Dir
> Loop
> Application.ScreenUpdating = True
> End Sub
>
> I am not able to execute it. Or u can say i m not able understand how
> the macro works.
> How the user can select files from a single folder. Instead of opening
> them.
>
> Awaiting for ur mail...
>
> Regards
>
> Akash
>


Akash

12/16/2006 5:18:00 AM

0

Dear Don,

Thanks for the Confirmation, I tried and i find that its working, I
beleave that i have found the perfect guy for the Excel tips. Amazing
work.

More over i want that if the macro is called it should prompt the user
to select the folder, so that user selects the foder and then the macro
extract file name in one column & the patch in the other column.

Is that possible

If yes pls do help me in this regards

Thanks

Akash



On Dec 15, 6:14 pm, "Don Guillett" <dguille...@austin.rr.com> wrote:
> The original post said to make a list on a worksheet. It should be fairly
> self explanatory. Just change the path to your folder/directory.
>
> --
> Don Guillett
> SalesAid Software
> dguille...@austin.rr.com"Akash" <maheshwari.ak...@gmail.com> wrote in messagenews:1166160247.268996.297280@f1g2000cwa.googlegroups.com...
>
> > Dear Don,
> > I was going through the earlier one of your mail on 14th Dec regarding
> > Paste filenames into cells
>
> > there u have given a code
>
> > Sub GetFileList()
> > Dim iCtr As Integer
>
> > With Application.FileSearch
> > .NewSearch
> > .LookIn = "c:\aa"
> > .SearchSubFolders = True
> > .Filename = ".xls"
> > If .Execute > 0 Then
> > For iCtr = 1 To .FoundFiles.Count
> > Cells(iCtr, 1).Value = .FoundFiles(iCtr)
> > Next iCtr
> > End If
> > End With
> > End Sub
> > =====
> > or DIR
>
> > Sub anotherfindfiles()
> > Application.ScreenUpdating = False
> > Dim FN As String ' For File Name
> > Dim ThisRow As Long
> > Dim MediaFileLocation As String
> > MediaFileLocation = "c:\yourfolder\*.xls"
> > FN = Dir(MediaFileLocation)
> > Do Until FN = ""
> > ThisRow = ThisRow + 1
> > Cells(ThisRow, 1) = FN
> > FN = Dir
> > Loop
> > Application.ScreenUpdating = True
> > End Sub
>
> > I am not able to execute it. Or u can say i m not able understand how
> > the macro works.
> > How the user can select files from a single folder. Instead of opening
> > them.
>
> > Awaiting for ur mail...
>
> > Regards
>
> >Akash