I have some code in an Outlook form that checks to see if a file is open before sending. It works fine, but once the form is able to be sent after the spreadsheet is available, it automatically closes my Outlook. If the file isn't open, and it is able to send without closing my Outlook. I am thinking that there is something in this segment of code that when the statement is true once is causes my problems. Any suggestions on why this might happen or any 'smoother' way of doing this? Thanks!
Set oWrkBook = oExcel.Workbooks.Open (FileLoc, 3, , , "purple" ,"purple",True)
If oWrkBook.ReadOnly Then
MsgBox ("You must wait for the log to become available."
oWrkBook.Close 0
Item_Send = False
End If
Set oWrkBook = oExcel.Workbooks.Open (FileLoc, 3, , , "purple" ,"purple",True)
If oWrkBook.ReadOnly Then
MsgBox ("You must wait for the log to become available."
oWrkBook.Close 0
Item_Send = False
End If