如何在Vb 2010中禁用Excel中的“另存为”

时间:2011-09-20 16:30:30

标签: vb.net visual-studio-2010

嗯..我如何禁用“另存为”按钮,我可以通过vb net打开Excel,但事情是我还想禁用“另存为”作为Ms Excel Open ...请帮助我感谢! :)但不是在宏..

这是我的代码:

  Imports Excel = Microsoft.Office.Interop.Excel

    Dim oXL As Excel.Application
    Dim oWB As Excel.Workbook
    Dim oSheet As Excel.Worksheet

    ' Start Excel and get Application object.
    oXL = CreateObject("Excel.Application")
    oXL.Visible = True
    oXL.WindowState = Excel.XlWindowState.xlMaximized
    ' Get a new workbook.
    oWB = oXL.Workbooks.Add
    oSheet = oWB.ActiveSheet

如何禁用“另存为”? :)

1 个答案:

答案 0 :(得分:0)

了解处理BeforeSave事件:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If SaveAsUI Then
        Cancel = True
    End If
End Sub

可以使用RibbonX禁用功能区上的实际按钮,但仍然存在允许用户保存的解决方法。