Opening a "Dummy"-file if file not exists

blaksnm

Well-known Member
Joined
Dec 15, 2009
Messages
554
Office Version
  1. 365
Platform
  1. Windows
Hey guys :)
Todays problem:

I make a list of all files in a folder. I choose one of the files from this list as default. The path/filename is placed in
Sheet("FileOpen") Range("A1").
During my session I must have the oportunity to use a Dummy-file instead of one of the valid ones in the list. This dummy has to be placed in a different folder than the folder my list is made by, like:

.. " if file (tryed to open) not exist (in folder my list is made by) - then open a reele dummy placed somewhere else ..." - kind of action

How to I create this test in my macro?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi. Perhaps like this

Code:
Sub OpenFile()
Dim FName As String
FName = Sheets("FileOpen").Range("A1").Value
If Dir(FName) = "" Then
    Workbooks.Open Filename:="C:\Dummy.xls"
Else
    Workbooks.Open Filename:=FName
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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