VBA Open Hidden Workbooks Question

Oldrat

New Member
Joined
Oct 23, 2017
Messages
5
Hi
I am trying to open hidden workbooks using vba then change the attributes to vbnormal, if I use the specific workbook name, this code works fine.

Code:
Sub Macro1()
Workbooks.Open Filename:="D:\Lee\Downloads\KLT-TempZvQkUb084152"
    MsgBox ActiveWorkbook.Name
    SetAttr ActiveWorkbook.FullName, vbNormal
End Sub

But I am trying to find and change any workbooks in the folder with a common part file name.
The code below appears to work to find and open workbooks that are visible, but does not find the hidden ones.

Code:
Sub OpenFiles()
    
    Dim Filepath As String
    Dim Findfile As String
    
    Filepath = "D:\Lee\Downloads\" 
    Findfile = Dir(Filepath & "\KLT-TempZvQkUb*.xls")
    
    Do Until Findfile = ""
        Workbooks.Open Filename:=Filepath & "" & Findfile
        Findfile = Dir
    Loop
    
End Sub

Could someone tell me what I'm doing wrong please ?:biggrin:
Many Thanks
Lee
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi & welcome
Untested, but maybe
Code:
Findfile = Dir(Filepath & "\KLT-TempZvQkUb*.xls"[COLOR=#ff0000], vbHidden[/COLOR])
 
Last edited:
Upvote 0
Hi Fluff

Thanks that works,
I've spent so much time looking for this, and oops..... do I feel silly not for working that one out !
Thanks again

Lee
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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