2013-02-21 55 views
1

我有一个按钮的应用程序。此按钮是指我在SharePoint上使用的Excel文档。但是,它会下载文件,这意味着它是只读的。现在,有一个在的SharePoint在编辑模式下打开文件的选项,我想我的按钮做同样的 - 我该如何使用链接href链接到的文件,并在编辑模式下打开它?的SharePoint 2010:链接打开Excel文件在编辑模式模式

enter image description here

我怎样才能做同样的动作为“Microsoft Excel中编辑”使用SharePoint外的按钮?就像文件的链接,它将以编辑模式打开它。

回答

0

Workbooks对象有你需要的功能:CanCheckOut,以确保它的可用和Google 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,但远远超出了我的知识

+0

我在哪里可以把这个代码?在SharePoint的Excel电子表格里面? – Homie 2013-02-28 10:49:03

+0

这将进入带来的电子表格中的代码 - 的例子是写在Excel中VBA – SeanC 2013-02-28 13:07:26

+0

是什么让电子表格是一个HTML按钮(

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 
相关问题