View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default how to open all hidden .xls files

There's a second parm you can pass to the dir() function.

excelfile = Dir(path & "*.xls"), vbHidden)

VBA's help has more information.

calebjill wrote:

I have some code to open all excel files in a folder, but it will only open
the files that are not hidden. Is there a way to open all the files
regardless of hidden status.

Here is the code.

Sub open_all_files()
Dim path As Variant
Dim excelfile As Variant
path = "c:/users/caleb/documents/commissions experiment/"

excelfile = Dir(path & "*.xls")
Do While excelfile < ""
Workbooks.Open Filename:=path & excelfile
excelfile = Dir
Loop
End Sub

Thanks


--

Dave Peterson