I'm not sure why.. but when I try to make a workbook that I opened, from sharepoint, to be active it gives me a run time error specifically on this line of code..
Workbooks(wb.Name).Activate
Here is my full code.
Sub CheckOut()
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim xlFile As String
xlFile = "https://microsoft.sharepoint.com/blah/blah/blah"
If Workbooks.CanCheckOut(xlFile) = True Then
Workbooks.CheckOut xlFile
Set xlApp = New Excel.Application
xlApp.Visible = True
Set wb = xlApp.Workbooks.Open(xlFile, , False)
MsgBox wb.Name & " is checked out to you."
Else
MsgBox "You are unable to check out this document at this time. Please make sure it is not checked out to anyone, including you."
End If
Workbooks(wb.Name).Activate
ActiveWorkbook.Save
ActiveWorkbook.Close
ActiveWorkbook.CheckIn
End Sub
Any help would be greatly appreciated!
Thanks in advance.
Bookmarks