Why does the following code think that the file is always open? I am having issues getting the Else part of the If to fire. Also how do I get the file closed and not save changes? I just want the file closed so I can use it. It is a .XML file.
Dim i As Integer
For i = 1 To Application.Workbooks.Count
bIsOpened = bIsOpened Or (Application.Workbooks(i).Name = "SALESORDERDOWNLOAD.XML" _
And Application.Workbooks(i).Path = "C:\_SAP\Extracts\SalesOrd")
If bIsOpened Then
MsgBox "Target save file is open, Closing file so process can use it.", vbOKOnly + vbInformation, "Cannot have: C:\_SAP\EXTRACTS\SALESORD\SALESORDERDOWNLOAD.xml open and run this process. Close it and try again."
Application.DisplayAlerts = False
Application.DisplayAlerts = True