View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Stripping out text?

Hi Terry,

Am Thu, 14 Dec 2017 09:33:14 +0000 schrieb Terry Pinnell:

https://www.dropbox.com/s/ma8cqc9qfp...ion-1.jpg?dl=0

Or
https://www.dropbox.com/s/ma8cqc9qfp...on-1.jpg?raw=1


try the following code in a new workbook. It will write the hyperlinks
for all files in the folder and subfolders of your path in column F and
the size of the files in GB in column G.

Sub Test()
Dim FSO As Object
Dim objFolder As Object, objSubFolder As Object, objFile As Object
Dim MyPath As String
Dim i As Long

Set FSO = CreateObject("scripting.fileSystemobject")
MyPath = Range("A1").Value
Set objFolder = FSO.getfolder(MyPath)

i = 2
For Each objFile In objFolder.Files
ActiveSheet.Hyperlinks.Add _
anchor:=Cells(i, "F"), _
Address:="file:///" & MyPath & objFile.Name, _
TextToDisplay:=objFile.Name
Cells(i, "G") = Format(objFile.Size / 1000000000, "0.000") & " GB"
i = i + 1
Next
For Each objSubFolder In objFolder.subfolders
For Each objFile In objSubFolder.Files
ActiveSheet.Hyperlinks.Add _
anchor:=Cells(i, "F"), _
Address:="file:///" & MyPath & objFile.Name, _
TextToDisplay:=objFile.Name
Cells(i, "G") = Format(objFile.Size / 1000000000, "0.000") & " GB"
i = i + 1
Next
Next
End Sub


Regards
Claus B.
--
Windows10
Office 2016