我有一个带按钮的应用程序。此按钮指的是我在SharePoint上的Excel文档。但是,它会下载文件,这意味着它是只读的。现在,SharePoint中有一个选项可以在编辑模式下打开文件,我希望我的按钮也能这样做 - 如何使用链接href
链接到文件并在编辑模式下打开它?
如何使用SharePoint外部的按钮执行与“在Microsoft Excel中编辑”相同的操作?就像文件的链接一样,它将以编辑模式打开它。
答案 0 :(得分:2)
这不是"在Microsoft Excel中编辑"选项,但"退房"。
To"在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
答案 1 :(得分:0)
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
还在this page上进行了更详细的讨论,但这远远超出了我的知识