ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy and paste file name (https://www.excelbanter.com/excel-programming/392878-copy-paste-file-name.html)

sebastico

Copy and paste file name
 
Hello.
I have a file with 2000 photos (jpg) and I need to copy the name of all
photos at a time and paste into a xls file. How can I do this?
Any help is welcome

Sorry if this question does not belong to this community. If not could you
suggest me where to address my question.

Thanks


Jim Cone

Copy and paste file name
 

Sub ListAllFilesInFolder()
'James Cone - San Francisco, USA - Oct. 2006
Dim strPath As String
Dim oFSO As Object
Dim oFile As Object
Dim oFolder As Object
Dim N As Long
N = 1
strPath = "C:\Documents and Settings\user\My Documents\My Pictures" '<<<
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(strPath)
Cells(N, 1).Value = oFolder.Path
N = N + 1
For Each oFile In oFolder.Files
Cells(N, 2).Value = oFile.Name
N = N + 1
Next 'oFile
Set oFSO = Nothing
Set oFile = Nothing
Set oFolder = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"sebastico"

wrote in message
....
Hello.
I have a file with 2000 photos (jpg) and I need to copy the name of all
photos at a time and paste into a xls file. How can I do this?
Any help is welcome

Sorry if this question does not belong to this community.
If not could you suggest me where to address my question.

Thanks



All times are GMT +1. The time now is 09:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com