Bill Bisco
Custom User Title
- Local time
- Today, 14:18
- Joined
- Mar 27, 2009
- Messages
- 92
Dear all,
I apologize for the thread. I have looked up similar threads, but am still having trouble. Any help would be appreciated.
This VBA Code is being executed from Access. I am trying to make a code to check if an Excel workbook is open and if it is open, to close the workbook. The workbook needs to be closed because further VBA code is going to delete the folder containing the Excel workbook. I am using the following code currently:
Currently, no file is closed with the above code. What am I doing wrong?
I apologize for the thread. I have looked up similar threads, but am still having trouble. Any help would be appreciated.
This VBA Code is being executed from Access. I am trying to make a code to check if an Excel workbook is open and if it is open, to close the workbook. The workbook needs to be closed because further VBA code is going to delete the folder containing the Excel workbook. I am using the following code currently:
Code:
'the following function will get the path only (i.e. the folder) from the file's full path:
Function FilePath(strPath As String) As String
FilePath = Left$(strPath, InStrRev(strPath, "\"))
End Function
Code:
Sub test22()
Dim Source As String, Wb As Workbook
Source = FilePath(CurrentProject.FullName) & "Resources\HPUCPUDataEntry.xlsm"
Set Wb = Workbooks.Open(Source)
Workbooks(Wb.Name).Close
End Sub