Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to CheckIn a checked out file in VBA?

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 he

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
error msg despite file have been checked & redone Jen Excel Discussion (Misc queries) 3 January 24th 09 09:15 AM
Method 'CheckIn' of object '_workbook' failed Bill Schanks Excel Programming 1 May 9th 06 10:04 PM
Can I insert a box on excel that can be checked and un-checked? rstang66 Excel Discussion (Misc queries) 1 December 17th 05 09:56 PM
Checkin into SPS prompts no matter what... Lasse Bjerre Knudsen Excel Programming 0 June 29th 04 08:46 AM
checkbox - default checked or un-checked barrfly Excel Programming 1 December 22nd 03 05:00 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"