This is the code i'm using now and its working perfect, the one thing it doesnt do it check for the file type. the only thing i want it to bring the file name in for is *.xls*
i dont see where to edit the code to have that check. :/
This checks a folder and brings all the file names into column A2 and down. also they are hyper linked to the file. its brining in PDFs and other stuff too though, just want excel type files. xlsx, xlsm etc.
thanks!
i dont see where to edit the code to have that check. :/
Code:
Sub FileHyperlinks()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder(ThisWorkbook.path & "\All Items\")
i = 1 'The row is starts on (binary)0 = row 1 and 1 = row 2 etc..
'Selects the page # to enter values to (doesn't matter what the page name is)
Sheet1.Activate
'loops through each file in the directory
For Each objFile In objFolder.Files
'select cell (I think the ,1 is column A "1")
Sheet1.Range(Sheet1.Cells(i + 1, 1), Sheet1.Cells(i + 1, 1)).Select
'create hyperlink in selected cell
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:= _
objFile.path, _
TextToDisplay:=objFile.Name
i = i + 1
Next objFile
End Sub
This checks a folder and brings all the file names into column A2 and down. also they are hyper linked to the file. its brining in PDFs and other stuff too though, just want excel type files. xlsx, xlsm etc.
thanks!
Last edited: