I use Excel files to generate reports from my Access applications as they are more useful than the reports that come out of Access. Generally I build templates with the desired column widths and other desired formatting (for cells where it doesn't change). To protect the template files I do it like this:
If Dir(g_strDE_SnapshotTemplate_File) <> "" Then
All those "g_str" items are global constants that store the path and file name.
The problem is that sometimes users try to run the report a second time without closing the first file. This throws a runtime error.
In VB 2010 I could manage this with a "Try/Catch" method that gave the user a message box if the attempt to open the file errored out.
Is there a way to test if that file is open in Access so I can give the user a Message Box warning and exit the subroutine rather than throwing the run time error?