Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193

    Question Hiding Options in File Menu

    Hi all



    Thanks for reading.

    I've been trying for ages to find a way to disable the File|Option dialog in my front end to start locking down the DB.

    I've created a custom ribbon but it doesn't work, whereas all of my research says that it should. The USysRibbons table is in the front end of the DB. I also want to get rid of the whole File and Tell Me menu's and haven't found a way to do that either. The various YouTube clips and forum posts, whilst helpful, haven't provided me with any solutions that work. Chat GPT just ended going round in circles! Does anyone have any clue as to how I achieve this.

    Code:
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
     <ribbon startFromScratch="false"></ribbon>
    <backstage>
    <button idMso="ApplicationOptionsDialog" visible = "False"/>
    </backstage>
    </customUI>

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    The simplest solution is just to hide the ribbon completely.
    However if you don’t want to do that, you can remove any or all of the File menu items by suitably modifying the USysRibbons data to leave a completely empty File backstage view. It isn’t possible to hide the File menu itself.

    See my web article https://isladogs.co.uk/improve-security-2 for details.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    Quote Originally Posted by isladogs View Post
    The simplest solution is just to hide the ribbon completely.
    However if you donÂ’t want to do that, you can remove any or all of the File menu items by suitably modifying the USysRibbons data to leave a completely empty File backstage view. It isnÂ’t possible to hide the File menu itself.

    See my web article https://isladogs.co.uk/improve-security-2 for details.
    Thank You.

    You're not going to believe me but I found your website 3 minutes after posting and it works a treat. The only issue is that there is a red line next to the File menu, which doesn't look great.



    My other idea is to have a default ribbon pop up for reports that just shows Print and PDF options on it. I already have a custom shortcut menu for that, but it seems some users are more comfortable with the ribbon than right-clicking.
    Other than that I don't really want to have any other ribbons.

  4. #4
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You’re welcome.
    Depending on your version, you may also want to lock down the QAT separately.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  5. #5
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    Quote Originally Posted by isladogs View Post
    YouÂ’re welcome.
    Depending on your version, you may also want to lock down the QAT separately.
    Hi Colin. I'll look at that also.

    I'm still struggling with the File Menu. When the application starts a login form opens with the ribbon, BlankRibbon, and the code below. So there is no ribbon and no menu, so far so good

    Code:
    Private Sub Form_Load()
        ' Hide the Access ribbon - but enable it again for reports
        DoCmd.ShowToolbar "Ribbon", acToolbarNo
        On Error Resume Next
        On Error GoTo 0
    End Sub

    In my USysRibbons table I have these Ribbons;

    BlankRibbon
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="true">
    <tabs>
    <!-- no tabs -->
    </tabs>
    </ribbon>
    </customUI>

    SimpleFile - Your ribbon that disables the File menu - Not currently called because BlankRibbon works fine, but I'm using it for reference.
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="true">
    <tabs>
    <tab idMso="TabHomeAccess" visible="false"/>
    <!-- no tabs -->
    </tabs>
    </ribbon>
    <backstage>
    <tab idMso ="TabPrint" visible="false"/>
    <button idMso ="ApplicationOptionsDialog" visible="false"/>
    <button idMso="FileExit" visible ="false"/>
    <tab idMso ="TabOfficeFeedback" visible ="false"/>
    <tab idMso ="TabInfo" visible ="false"/>
    </backstage>
    </customUI>

    ReportPrintRibbon - A custom ribbon that is loaded when I generate reports
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon startFromScratch="true">
    <tabs>
    <tab id="tabReportPrint" label="Report Print">
    <group id="grpPrint" label="Printing">
    <button id="btnQuickPrint"
    label="Quick Print"
    size="large"
    imageMso="FilePrintQuick"
    onAction="=DoCmd.RunCommand(acCmdPrint)" />
    <button id="btnExportPDF"
    label="Export as PDF"
    size="large"
    imageMso="ExportPdfWord"
    onAction="=DoCmd.OutputTo(acOutputReport, , acFormatPDF)" />
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI>

    The problem I'm having is that when ReportPrintRibbon is activated when areport opens, the File option appears (on the menu bar and the user has access to everything under it, and when the report closes I have a ribbon showing File & Home as well as as the QAT.

    I've tried incorporating your ribbon code into the ReortPrintRibbon, but am not having any success with preventing the File menu option appearing and restoring the interface to no menus and ribbons when the report closes. I don't have a default ribbon set in the Current Database options and I also have Allow Full Menus and Allow Default Shortcut Menus disabled.

    Any insights would be greatly appreciated.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't use ribbon for print options, I just offer the QAT. It's been a while since I built this. I probably need to update but it still works.
    Code:
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
      <commands>
        <command idMso="Help" enabled="false"/>
      </commands>
      <ribbon startFromScratch="true">
        <officeMenu>
          <button idMso="FileOpenDatabase" visible="false"/>
          <button idMso="FileNewDatabase" visible="false"/>
          <button idMso="FileCloseDatabase" visible="false"/>
        </officeMenu>
        <qat>
          <documentControls>
             <button idMso="PrintDialogAccess"/>
          </documentControls>
        </qat>
      </ribbon>
    </customUI>
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    [QUOTE=June7;534921]I don't use ribbon for print options, I just offer the QAT. It's been a while since I built this. I probably need to update but it still works.

    Thanks June. I've given this a go, but as soon as the QAT is activated again, the File menu option appears below it, then when I close the report the File Home Tell Me menu options appear as well as the default QAT.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Well, I have not been able to get the File tab to hide but Home tab does. And it is still hidden after report closes. This ribbon customization is sooooo tricky.

    I do have default ribbon set in Database Options. It hides everything except File Options and File Exit and File Print (forgot Print was still there, maybe haven't figured out how to get rid of). I have code that prevents this Exit working.

    I tried your BlankRibbon and did not work for me.

    Seem to remember this all worked properly with 2007 when I built it but started to go haywire with 2010 upgrade.

    Right now testing with Access 2010. Will have to go try my 2021 machine.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    Thanks June.

    I've only just tarted with ribbon customisation and am beginning to think it's not worth the effort. My custom right click options work fine, it's just that a lot of users are expecting to see some sort of menu across the top of the screen.

  10. #10
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    Update.

    I think I'm on the right track, but still have the issue of the File option and QAT appearing when I invoke the custom print ribbon . The DB opens with no menus, ribbons or QAT. When the report opens the custom Print ribbon opens (but with the File menu option and QAT showing). When the report closes the ribbon is closed and there are no menus and QAT is closed.

    I've achieved this by;

    1. I don't have a default ribbon set in the Current Database options and I also have Allow Full Menus and Allow Default Shortcut Menus disabled.
    2. Created a couple of custom ribbons
      1. BlankRibbon
        Code:
        1. <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="true"> <tabs> <!-- no tabs --> </tabs> </ribbon> </customUI>
      2. ReportPrintRibbon
        Code:
        1. <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"> <ribbon startFromScratch="true"> <tabs> <tab id="tabReportPrint" label="Report Print"> <group id="grpPrint" label="Printing"> <button id="btnQuickPrint" label="Quick Print" size="large" imageMso="FilePrintQuick" onAction="QuickPrintCallback" /> <button id="btnExportPDF" label="Export as PDF" size="large" imageMso="FileSaveAsPdfOrXps" onAction="ExportPDFCallback" /> </group> </tab> </tabs> </ribbon> </customUI>
      3. Created a couple of public modules for the custom print ribbon
        1. Code:
          Public Sub QuickPrintCallback(control As IRibbonControl)
              On Error GoTo ErrHandler
              Dim rpt As AccessObject
              
              ' Loop through open reports, take the first one loaded
              For Each rpt In CurrentProject.AllReports
                  If rpt.IsLoaded Then
                      ' Open in Print Preview dialog so the user can choose a printer
                      DoCmd.OpenReport rpt.Name, acViewPreview, , , acDialog
                      
                      ' Once the preview is open, invoke the Print dialog
                      DoCmd.RunCommand acCmdPrint
                      
                      ' Close the preview after printing
                      DoCmd.Close acReport, rpt.Name, acSaveNo
                      
                      Exit Sub
                  End If
              Next rpt
              
              MsgBox "No active report to print.", vbExclamation
              Exit Sub
              
          ErrHandler:
              If Err.Number = 2501 Then
                  Resume Next
                  Else
                  MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "Quick Print"
              End If
          End Sub
          Code:
          Public Sub ExportPDFCallback(control As IRibbonControl)
              On Error Resume Next
              Dim rptName As String
              If Not Screen.ActiveReport Is Nothing Then
                  rptName = Screen.ActiveReport.Name
                  DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, , True
              Else
                  MsgBox "No active report to export.", vbExclamation
              End If
              On Error GoTo 0
          End Sub

      4. Added some events to the report.
        1. Code:
          Private Sub Report_Close()
          On Error GoTo Err_Handler
          
              DoCmd.ShowToolbar "Ribbon", acToolbarNo
              Forms![svc_Error Code Report].Visible = True
              
          Err_Handler:
              If Err.Number = 2450 Then
                  Err.Clear
                  Exit Sub    ' no active report, just exit quietly
              End If
          End Sub
          Code:
          Private Sub Report_Load()
              DoCmd.ShowToolbar "Ribbon", acToolbarYes
              Forms![svc_Error Code Report].Visible = False
          End Sub
          Code:
          Private Sub Report_NoData(Cancel As Integer)
              DoCmd.ShowToolbar "Ribbon", acToolbarNo
              'call handler from global module
              HandleNoData_CancelReport Me, Cancel
          End Sub




    I really don't want the File menu option or the QAT appearing.

    It all seems very complicated and I don't really want to duplicate all the event handlers for every report.

    I'm open to suggestions.

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Sorry but I rarely get email notifications from this site so wasn't aware of any posts after #4
    I haven't had time to read your ribbon XML / code in any detail.
    I'm posting now to remind you that the easiest solution is to completely remove the ribbon except for particular situations e.g. Print ribbon for reports in Print Preview.

    Have a look at my example database: Control the Application Interface where I do this and also hide the application interface. The example app shows lots of different scenarios.

    NOTE: In older versions such as 2010, the QAT was fully linked to the ribbon. You either had both or neither.
    This was changed a few tears ago and they are now handled separately at least in 365 (not sure about e.g. 2021). Unfortunately there is almost no info online on managing the QAT in code.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    Colin, if the QAT is separate in an Access version and you can have it without the Ribbon, then would the old custom commandbars and menus be an option? IIRC, any custom menus were placed in the QAT when the db opened. I realize that custom commandbars are no walk in the park either, but once you get the hang of it, it can be a matter of just copying and editing blocks of code.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Hi Micron
    Unfortunately not.
    Custom commandbars created in A2003 or earlier are added to an Add-ins ribbon when an old .mdb file is converted to .accdb. Badly named as they aren't add-ins but that was how it was done
    So nothing to do with the QAT as such.

    You can still create custom commandbars but unfortunately there is no built-in tool to do so in .accdb files.

    In general the QAT is easy to customise but trying to lock it down as the OP is trying to do here is more difficult.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  14. #14
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,422
    I just checked to see where it ends up because I couldn't recall. Turns out it goes into the Add Ins ribbon group.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    sheusz is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2015
    Posts
    193
    Quote Originally Posted by isladogs View Post
    .... I'm posting now to remind you that the easiest solution is to completely remove the ribbon except for particular situations e.g. Print ribbon for reports in Print Preview.

    Have a look at my example database: Control the Application Interface where I do this and also hide the application interface. The example app shows lots of different scenarios.

    NOTE: In older versions such as 2010, the QAT was fully linked to the ribbon. You either had both or neither.
    This was changed a few tears ago and they are now handled separately at least in 365 (not sure about e.g. 2021). Unfortunately there is almost no info online on managing the QAT in code.
    Hi Colin. Thanks for the response. We are using Office 365. I've had a look at you Control Application Interface. Lot's of nice stuff there that I can play with. However I don't see a solution in regards to the QAT.

    I already have the ribbon disabled globally
    Code:
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    and only activate it when a report opens with the reports OnLoad event, and close it with the reports OnClose event. Tedious if I have to do this for every report..
    Code:
    DoCmd.ShowToolbar "Ribbon", acToolbarYes
    The problem is that when the ribbon is enabled, the QAT is also enabled loaded with commands I don't want.

    The best solution I've been able to come up with is to "grey out" the commands in the QAT with my custom ribbon. Teasingly it still has the Hide Quick Application Toolbar Option, for which I haven't been able to find a idMso

    Code:
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
      <ribbon startFromScratch="true">
        <tabs>
          <tab id="tabReportPrint" label="Report Print">
            <group id="grpPrint" label="Printing">
              <button id="btnQuickPrint"
                      label="Quick Print"
                      size="large"
                      imageMso="FilePrintQuick"
                      onAction="QuickPrintCallback" />
              <button id="btnExportPDF"
                      label="Export as PDF"
                      size="large"
                      imageMso="FileSaveAsPdfOrXps"
                      onAction="ExportPDFCallback" />
            </group>
          </tab>
        </tabs>
    
        <!-- Empty QAT: greys out QAT strip and blocks customization -->
        <qat/>
      </ribbon>
    
      <!-- Remove Backstage (File menu) options -->
      <backstage>
        <tab idMso="TabInfo" visible="false"/>
        <tab idMso="TabRecent" visible="false"/>
        <tab idMso="TabNew" visible="false"/>
        <tab idMso="TabOpen" visible="false"/>
        <tab idMso="TabSave" visible="false"/>
        <tab idMso="TabPrint" visible="false"/>
        <tab idMso="TabShare" visible="false"/>
        <tab idMso="TabHelp" visible="false"/>
        <tab idMso="TabOptions" visible="false"/>
        <tab idMso="TabClose" visible="false"/>
      </backstage>
    </customUI>
    Click image for larger version. 

Name:	QAT.jpg 
Views:	15 
Size:	16.0 KB 
ID:	53221

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-19-2021, 06:34 PM
  2. Options Options Dialog
    By Mister-B in forum Modules
    Replies: 2
    Last Post: 05-10-2020, 01:07 AM
  3. Hiding/Disabling Toolbars and Editing Options
    By Torinjr in forum Security
    Replies: 4
    Last Post: 05-05-2015, 07:49 PM
  4. Replies: 6
    Last Post: 10-26-2012, 09:28 AM
  5. I can't see the menu options in Ms Access 2010.
    By dave_joseph in forum Access
    Replies: 2
    Last Post: 10-27-2011, 03:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums