Excel Validation failed In an unmodified Excel workbook in SharePoint using VBA

I'm working on a project that looks something like this:

if workbooks.canCheckOut(filename) = true then    
  workbooks.CheckOut(filename)
  set workbookVariable = workboooks.Open(filename)
else    
   ' Pesudocode: Display error message
   '             Quit
end if

' Pseudocode: Do some stuff with workbookVariable.    
If workbookVariable.saved = false then     
    workbookVariable.save
end if

If workbookVariable.canCheckIn then    
    workbookVariable.checkIn
    Set workbookVariable = Nothing
else    
    msgbox "Error message goes here", vbCritical
end if    
' Pseudocode: quit

(Edit: I had "If workbookVariable.Saved = True", which was incorrect. There is no point in saving the file if it is already saved ... So now it is updated to reflect what I really have.)

If the workbook is modified and saved, everything will work fine. It saves, is checked back to SharePoint, and the program ends normally.

However, if the workbook does not change, when it proceeds to check in part of the program, excel crashes, and I get an error message: "Automation error".

I even tried to include the wait command after the command checkIn, but no luck ...

? - ?

+5
1

(workbookVariable.saved = true), workbookVariable.CheckIn(False). , CheckIn , . , . "CheckOut". . MSDN.

, , .

: ?

0

All Articles