Ananthak275
Board Regular
- Joined
- Aug 22, 2020
- Messages
- 128
- Office Version
- 2013
- Platform
- Windows
- MacOS
My VBA script calls multiple macros, one of them is to open a file and if one of them doesn't exists then exits the sub. The following macros are dependent on the first macro calling the file location, and even if that sub exits, the following macros still run.
Sub Call_Process ()
Call File_Location
Call Open_File
Call Exit_WB
End Sub
Sub File_Location ()
location_db = "C:\Users\Documents\New folder\*.xl??"
End Sub ()
Sub Open_File ()
dim wb as Workbook
dim ws as Worksheet
if dir(location_db) = "" <- as you can see if the file doesnt exists, it exits out of Open_File sub but not the Exit_WB when im running the Call_Process
end sub
end if
wb_filename = wb.name
sheet_name = ws.name
End Sub
Sub Exit_WB
Workbooks(location_db).close savechanges=TRUE
End Sub