Consulting

Results 1 to 2 of 2

Thread: Disable commandbars in Excel 2007 - through VBA

  1. #1

    Disable commandbars in Excel 2007 - through VBA

    Hi,

    I have the below code which will disable SaveAs, Save, SendTo buttons if the cell value in C1= Error, this is working perfectly in excel 2003,

    Can someone help me to run the similar command in 2007 aslo, that is if the user is using 2003, then run this, else
    run the code for 2007.
    [vba]Option Explicit

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim LR As Long
    Dim row As Integer
    If Worksheets("Item Request Form").Range("E1").Value <> "HSC" Then
    If Worksheets("Item Request Form").Range("C1").Value = "Error" Then
    MsgBox "Sheet incomplete, please check", vbCritical, "Input required"
    ' Following line will prevent all saving
    Cancel = True
    ' Following line will prevent the Save As Dialog box from showing
    SaveAsUI = False
    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Send To").Enabled = False
    Else
    SaveAsUI = True
    Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Send To").Enabled = True
    End If
    End If
    End Sub[/vba]

    Thanks for your help.
    Cross post: http://www.mrexcel.com/forum/showthread.php?t=598925

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You cannot do that in code in 2007. You need to add custom XML to a 2007 format workbook to alter parts of the ribbon.
    Be as you wish to seem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •