View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default CheckOut/CheckIn from/to SharePoint 2010

Nick H submitted this idea :
Yes, this works...

Private mXlApp As Excel.Application

Sub SPCheckOut(docCheckOut As String)
Set mXlApp = CreateObject("Excel.Application")
' Determine if workbook can be checked out.
If mXlApp.Workbooks.CanCheckOut(docCheckOut) = True Then
mXlApp.Workbooks.Open Filename:=docCheckOut
mXlApp.Workbooks.CheckOut docCheckOut
mXlApp.Visible = True
Else
MsgBox "Unable to check out this document at this time."
End If
End Sub

Sub SPCheckIn(docCheckIn As String)
' Determine if workbook can be checked in.
If mXlApp.Workbooks(docCheckIn).CanCheckIn = True Then
mXlApp.Workbooks(docCheckIn).CheckIn
Else
MsgBox "This file cannot be checked in at this time. Please
try again later."
End If
End Sub

Obvioulsy mXlApp should be disposed of properly elsewhere when
finished with.

Br, Nick.


mXlApp will be implicitly destroyed when the file containing the code
that created it terminates. However, it would be best to explicitly
destroy it BEFORE the file closes because anything we leave to VBA to
do implicitly requires extra processing on VBA's part. IMO, it's just
good programming practice to explicitly destroy objects we create when
we no longer need them.

Example:
Set mXlApp = Nothing

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc