+ Reply to Thread
Results 1 to 2 of 2

VBA code for hide ribbon { not woprking }

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    VBA code for hide ribbon { not woprking }

    Good morning all
    can please advice me what is problem in the following code
    this code for hide ribbon , tab , formula and full screen
    the problem is ribbon is hide after open but when minimize workbook then maximize again its show ribbon and allow to goto visual basic code although this is protected with password
    Private Sub Workbook_Open()
     Dim ws As Worksheet
    For Each ws In Worksheets
    
              ws.Activate                                       ' this part to hide the list 
        Application.DisplayFullScreen = True
        Application.DisplayFormulaBar = False
        ActiveWindow.DisplayGridlines = False
        ActiveWindow.DisplayHeadings = False
        Application.DisplayStatusBar = False
        Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
         ActiveWindow.DisplayWorkbookTabs = False
                                                 
                                         
    
    
        If ws.Name = "Sample ID test" Then                           ' this part to delete sample ID test sheet if present
            Application.DisplayAlerts = False
            Sheets("Sample ID test").Delete
            Application.DisplayAlerts = True
        End If
    
    
    Sheets("Data Entry").ScrollArea = "A1:F97"                                 ' this part to prevent scroll area 
    
    
    
    
    Sheets("Data Entry").Unprotect Password:="1234567"                ' this part to format range of cell but i enter unprotect line because its give me error if not used
    Sheets("Data Entry").Select
    Range("B2:B97").Select
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 16768648
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
            Selection.Borders(xlDiagonalDown).LineStyle = xlNone
            Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ThemeColor = 1
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ThemeColor = 1
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ThemeColor = 1
            .TintAndShade = 0
            .Weight = xlThin
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ThemeColor = 1
            .TintAndShade = 0
            .Weight = xlThin
        End With
            Selection.Borders(xlInsideVertical).LineStyle = xlNone
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .ThemeColor = 1
            .TintAndShade = 0
            .Weight = xlThin
        End With
    
                
        With Sheets("Data Entry").Select          ' this part for clear content
            Range("A2,C2,D2").Select
            Selection.ClearContents
            Range("B2:B97").Select
            Selection.ClearContents
        End With
            
            
      ws.Range("B2:B97").Locked = False
        ws.Range("A2").Locked = False
        ws.Range("C2:D2").Locked = False
    Sheets("Data Entry").Protect Password:="1234567"
    
    Next
    
    End Sub
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim ws As Worksheet
    For Each ws In Worksheets
                          ws.Activate
        If ws.Name = "Sample ID test" Then
                        Application.DisplayAlerts = False
                        Sheets("Sample ID test").Delete
                        Application.DisplayAlerts = True
                    End If
        
        Application.DisplayAlerts = False
            ThisWorkbook.Saved = True
        Application.DisplayAlerts = True
        Next
    End Sub
    all this code i put in thisworkbook

  2. #2
    Forum Contributor
    Join Date
    11-28-2013
    Location
    Ljubljana
    MS-Off Ver
    Office 365
    Posts
    1,054

    Re: VBA code for hide ribbon { not woprking }

    Any advice

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ribbon Hide
    By moktr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-25-2020, 10:04 AM
  2. Hide ribbon
    By moktr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2020, 07:45 PM
  3. Hide Ribbon
    By Toby1982 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-08-2019, 01:37 PM
  4. VBA Code to hide Ribbon Bar
    By pmgibbs79 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-30-2016, 12:13 AM
  5. [VBA CODE] Excel - Hide Ribbon but leave File menu
    By cityinbetween in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2014, 09:55 PM
  6. [SOLVED] Hide Ribbon
    By pedjvak in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2013, 03:01 AM
  7. Code to hide Ribbon
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-06-2012, 04:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1