如何在Sharepoint上签入文件?

时间:2018-07-31 06:14:16

标签: vba sharepoint checkin

我编写了以下代码,用于通过Sharepoint上的VBA检入文件。

Dim strWkbCheckIn As String

strWkbCheckIn = spBASE_URL + spDOC_LIB + "/" + spFILE_NAME

' Determine if workbook can be checked in.
If Workbooks(strWkbCheckIn).CanCheckIn = True Then
   Workbooks(strWkbCheckIn).CheckIn
   MsgBox ("checked in.")
Else
   MsgBox ("This file cannot be checked in ")
End If

但是它显示以下错误:

Run-time error '9':
Subscript out of range

我已经检查了共享点上是否确实存在该文件。但是仍然出现此错误。只是一个疯狂的猜测,是否有可能因为文件已签出并向我签出,所以程序看不到它?

1 个答案:

答案 0 :(得分:1)

这应该为你做。

Sub testing()
    Dim docCheckOut As String
    'docCheckOut = "//office.bt.com/sites/Training/Design Admin/Training Plan/adamsmacro.xlsm"
    docCheckOut = "http://excel-pc:43231/Shared Documents/ExcelList.xlsb"
    Call UseCheckOut(docCheckOut)
    Call UseCheckIn(docCheckIn)
End Sub

Sub UseCheckOut(docCheckOut As String)
     ' Determine if workbook can be checked out.
    If Workbooks.CanCheckOut(docCheckOut) = True Then
        Workbooks.CheckOut docCheckOut
    Else
        MsgBox "Unable to check out this document at this time."
    End If
End Sub

Sub UseCheckIn(docCheckIn As String)
     ' Determine if workbook can be checked out.
    If Workbooks.CanCheckIn(docCheckIn) = True Then
        Workbooks.CheckIn docCheckIn
    Else
        MsgBox "Unable to check in this document at this time."
    End If
End Sub