SharePoint 2010:链接以编辑模式打开Excel文件

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

在这里输入图像说明

如何使用SharePoint外的button执行与“在Microsoft Excel中编辑”相同的操作? 就像链接到将在编辑模式下打开它的文件。

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

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

 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 

Workbooks对象具有您需要的function: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 

也在这个页面上进行了更详细的讨论,但这远远超出了我的理解

Interesting Posts