I the following code I am checking to see if a specific file is open, if it is? Close it, if not? carry on.
Ln7 concerns me because it is an absolute folder location. Is there a way to write that part out?
I have another procedure that uses that file and it needs to be closed in order to process correctly.
Please advise and thanks.
PS: Will consider other re-writes too. It shows my lack of VBA writing skills.
Dim I As Integer
For I = 1 To Application.Workbooks.Count
If (Application.Workbooks(I).Name = "SALESORDERDOWNLOAD.XML" _
And Application.Workbooks(I).Path = "C:\_SAP\Extracts\SalesOrd") Then
bIsOpened = True
' 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")
' Next i
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
bIsOpened = False
Application.DisplayAlerts = True
GoTo 100 'Removed Exit Sub
100 'Continue knowing that file is not open.