Excel 2019 VBA Dir() function

JamesPW

New Member
Joined
Nov 4, 2005
Messages
42
Office Version
  1. 2019
Platform
  1. MacOS
I transferred a Excel 2011 macro to Excel 2019 and the code is failing on the Dir() command.
I have code that appends the file name with the date. Then it checks to see if the newfile (NewPathFileExt) already exists.
If it does I prompt "Do you want to overwrite it" Y/N
If it doesn't I write the new file to that location.
The code FileThere = (Dir(NewPathFileExt) > "") gives the following if file NewPathFileExt exists. It runs ok if NewPathFileExt does not exist

Screen Shot 2020-07-22 at 1.30.39 PM.png


I understand this has something to do with VBA is sandboxed in Excel 2019.
I've tried all sorts of commands with no success.
What code will tell me if the file exists without asking for permission??
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Watch MrExcel Video

Forum statistics

Threads
1,119,258
Messages
5,577,023
Members
412,762
Latest member
Philfy
Top