How do I ignore hidden files?

JJabra

New Member
Joined
Aug 19, 2019
Messages
37
Hi, I currently have the below code to pull a list from a file path every time the worksheet is activated.

Sub worksheet_Activate()

Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("Y:\A6 Training\Note Templates\Disputes")
i = 1
For Each objFile In objFolder.Files
Cells(i + 1, 62) = objFile.Name


i = i + 1
Next objFile
End Sub

This works well, however the code is now pulling ~$files which I understand is when the word docs that I'm pulling through are open.

Please can somebody advise if they know a way of stopping the hidden files pulling through?

Thanks in advance
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Can't you just do this?

Rich (BB code):
For Each objFile In objFolder.Files

If Left(objFile.Name,1)<>"~" then
    Cells(i + 1, 62) = objFile.Name
    i = i + 1
End If
Next objFile
End Sub
 
Upvote 0
Can't you just do this?

Rich (BB code):
For Each objFile In objFolder.Files

If Left(objFile.Name,1)<>"~" then
    Cells(i + 1, 62) = objFile.Name
    i = i + 1
End If
Next objFile
End Sub

Hi I tried this and it still seems to be Pulling through the ~$ files
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top