Cannot open hidden Excel Workbook

oseitutuSamuel

Board Regular
Joined
Jul 31, 2015
Messages
80
Hello People,

I need help. I have two Excel Workbooks (call them WorkbookA and WorkbookB). I have code in a command button in WorkbookA to open WorkbookB.
Everything works fine until I hide WorkbookB (using the OS, so you cannot see WorkbookB). When I do this the VBA code behaves as if WorkbookB does not exist.

Is there any way to go around this?

Thanks & Regards,
Samuel
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Kamolga

Well-known Member
Joined
Jan 28, 2015
Messages
1,176
Hi,
You need to add vbHidden ​to the full path of the file.
Code:
[LEFT][COLOR=#333333][FONT=monospace]Sub OpenFiles()
    
    Dim Filepath As String
    Dim Findfile As String
    
    Filepath = "[/FONT][/COLOR][B][COLOR=#008000]D:\User\Downloads\[/COLOR][/B][COLOR=#333333][FONT=monospace]" 
[/FONT][/COLOR]
[COLOR=#333333][FONT=monospace]    Findfile = Dir(Filepath & "[/FONT][/COLOR][COLOR=#008000][B]\WorkbookB.xls[/B][/COLOR][COLOR=#333333][FONT=monospace]"[COLOR=#ff0000], vbHidden[/COLOR])
[/FONT][/COLOR]
[COLOR=#333333][FONT=monospace]    
        Workbooks.Open Filename:=Filepath & "" & Findfile

    
End Sub[/FONT][/COLOR][/LEFT]
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,127,144
Messages
5,622,993
Members
415,944
Latest member
loribear180

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
Top