1

我有一个带有按钮的应用程序。此按钮指的是我在 SharePoint 上的 Excel 文档。但是,它将下载文件,这意味着它是只读的。现在,SharePoint 中有一个选项可以在编辑模式下打开文件,我希望我的按钮也可以这样做 - 如何使用链接href链接到文件并在编辑模式下打开它?

在此处输入图像描述

如何使用 SharePoint 外部的按钮执行与“在 Microsoft Excel 中编辑”相同的操作?就像一个指向文件的链接,它将在编辑模式下打开它。

4

2 回答 2

2

这不是“在 Microsoft Excel 中编辑”选项,而是“签出”选项。

要“在 Microsoft Excel 中编辑”,解决方案非常简单。在 Workbook_Open 中只做 ActiveWorkbook.LockServerFile。该命令的文档说它锁定了工作簿,但在这种情况下,它的作用完全相反,它只是执行编辑栏问题。

Private Sub Workbook_Open()

'The following command is equivalent to hitting the "Edit" bar 
'that comes up when you open an Excel file by clicking on it in SharePoint,
'which is equivalent to "Edit in Microsoft Excel" (not CheckOut)

ActiveWorkbook.LockServerFile

End Sub
于 2014-09-18T17:39:44.977 回答
1

Workbooks对象具有您需要的功能:CanCheckOut 确保它可用,CheckOut 用于打开文件进行编辑

此代码将获取文件的名称(如http://server:port/PathToFile/myExcelFile.xlsx)并在可能的情况下打开它

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

网页的vbscript:

set objExcel = CreateObject("Excel.Application")
drPath = "server\file"
if (objExcel.Workbooks.CanCheckOut(drPath) = True) then
    objExcel.Application.Workbooks.CheckOut drPath //note - may need to open first
    objExcel.Application.Workbooks.Open drPath
else
    msgbox("Unable to checkout SharePoint file: " & file.name & ". Please contact an administrator.")
end if

在此页面上也进行了更详细的讨论,但这远远超出了我的知识范围

于 2013-02-21T15:56:38.580 回答