Radoslaw Poprawski
Active Member
- Joined
- Jun 19, 2021
- Messages
- 398
- Office Version
- 365
- Platform
- Windows
Hi All, i have a small code:
My issue is when I try running the first 2 lines i get an error:
since xRet is boolean in result, then why cant I simply pass it to another function as boolean?
VBA Code:
xRet = IsWorkBookOpen(WBName)
Call DeleteFiles(WBName, xRet)
VBA Code:
Function IsWorkBookOpen(Name As String) As Boolean
Dim xWb As Workbook
On Error Resume Next
Set xWb = Application.Workbooks.Item(Name)
IsWorkBookOpen = (Not xWb Is Nothing)
End Function
VBA Code:
Sub DeleteFiles(WBName As String, xRet As Boolean)
With New FileSystemObject
If xRet Then Workbooks(WBName).Close
If .FileExists(Path & WBName) Then
.DeleteFile Path & WBName
End If
End With
End Sub
since xRet is boolean in result, then why cant I simply pass it to another function as boolean?