PC Review


Reply
Thread Tools Rate Thread

How to CheckIn a checked out file in VBA?

 
 
Revolvr
Guest
Posts: n/a
 
      12th Aug 2009
Hi all,

In an Excel VBA subroutine, I need to check out a file (of
SharePoint), change a few records, then save the changes and check the
file back in. So far I have been able to check out the file, open it,
modify it, but then I get stuck.

The examples I started with came from here:

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

The test subroutine I am using is below. I am able to check out the
file. After that I can open the file and make changes. What I cannot
do so far is check in the file. You can see from the various
permutations I have tried, in the comments, what my results are. If I
just stop the code when it breaks, I can manually check in the file.

The file path is a named range on the worksheet, as is the name of the
worksheet to modify.

Can anyone show me what I am doing wrong?

Thanks!

Sub testcheckinout()
Dim dbpath As String
Dim wbk2 As Workbook
Dim sdbsheet As String

dbpath = Range("DBpath").Value
sdbsheet = Range("DBsheet").Value

If Workbooks.CanCheckOut(dbpath) = True Then
Workbooks.CheckOut dbpath
Else
MsgBox "Unable to check out this document at this time."
Exit Sub
End If

' should be checked out. Now open it
Set wbk2 = Workbooks.Open(dbpath, , False)
Set dbsheet = wbk2.Sheets(sdbsheet)

' Modify a cell
dbsheet.Cells(2, 1) = "This is a change " & Date & " at " & Time

' Save changes. But if I do this I cannot check in the file
'wbk2.Close SaveChanges:=True
' check in

'If Workbooks(dbpath).CanCheckIn = True Then ' fails - subscript
out of range
If wbk2.CanCheckIn = True Then ' fails, automation error if file
is closed first
'Workbooks(dbpath).CheckIn ' fails, subscript out of range
'wbk2.CheckIn ' fails, automation error
'wbk2.CheckIn ' fails, method checkin of object
'Workbooks(2).CheckIn ' fails, method checkin of object
'Workbooks.CheckIn dbpath ' this doesn't compile
Workbooks(dbpath).CheckIn ' fails, subscript out of range
MsgBox dbpath & " has been checked in."
End If

End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Version checkin error in XP PRo hubbly59139 Windows XP Help 1 14th Feb 2008 02:44 AM
Checkin/Out Database =?Utf-8?B?a2lkZGp0?= Microsoft Access 2 8th Jun 2006 07:18 PM
Auomatically checkin for new mail? =?Utf-8?B?UmV0aXJlZCBpbiBTYXZhbm5haA==?= Microsoft Outlook Installation 1 7th Aug 2005 04:29 AM
Help! Too Complicated - CheckIn/CheckOut Jennay via AccessMonster.com Microsoft Access Forms 1 11th Feb 2005 08:39 PM
checkin/checkout problem SuperGumby Microsoft Frontpage 7 8th Nov 2003 02:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:14 PM.