I am being thrown an unexpected error message from excel when I include the following line in my workbook open procedure:
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
The following error is displayed in the active window after the workbook loads:
ExcelError.jpg
I want to fully hide the ribbon and not minimize it (like SendKey ^F11) so the user does not have the ability to access it (mainly to remove copy/pasting from the clipboard ribbon), hence my use of an Excel 4 Macro as opposed to ExecuteMso or the other few methods that may exist. I have even tried housing the line within a loop that checks the status of the ribbon to ensure it does not attempt to hide when hidden or show when shown (using Get.ToolBar(7, "Ribbon")). No matter what I do this code creates the error. The workbook still functions properly as if the error did not change anything but I would still like to get rid of it and/or find out why it is happening. The workbook and worksheets inside are usually protected but during the open procedure I begin by unlocking the structure and all of the sheets so that should not be the issue. I have this line, and a function that disables cut/copy/paste in the following events:workbook_open, workbook_close (opposite boolean values), workbook_activate, workbook_windowactivate, workbook_deactivate (opposite boolean values), and workbook_windowdeactivate (opposite boolean values)
to ensure it only applies to the current workbook. Whenever the aforementioned line is commented out, the workbook opens without the error showing up. Does anyone know what is causing this/how to fix it? Or even just how to suppress the error message? - I have attempted Application.DisplayAlerts = False prior to the Excel4Macro with no success
Below are the Copy Details from the error message minus the stack trace (Forum won't allow me to paste it in):
Feedback Type:
Frown (Error)
Error Message:
Exception from HRESULT: 0x800A03EC
Bookmarks