Cannot open hidden Excel Workbook

oseitutuSamuel

Board Regular
Joined
Jul 31, 2015
Messages
82
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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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:
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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