# Excel custom ribbon disappears when running macro



## avcape (Dec 31, 2022)

I have a custom ribbon in Excel with macros assigned to it. One set of macros does just sheet/column formatting, sort data etc. Normal Excel stuff. Those all works.

Then I have two specific macros that removes the custom ribbon completely when they execute. Well, after the executed the Custom ribbon is gone.
After running these macros the customUI14.xml file is gone completely. The .xml file is just not there using the ‘Office RibbonX Editor’. The reference to the customUI14.xml file is also gone from within the _rels file.

These two macros each call a Python file outside Excel. The one macro calls a exe that automatically imports csv file and the other does all the formala calculation externally. No formulas in this sheet.

These macros runs fine with a custom ribbon that is created using the standard options in Excel. This same ribbon is displayed then on every excel menu.
They run fine when running the Macro directly or through the VB interface when using the standard ribbon with macros assigned to it..

I created a custom ribbon is just for this sheet using ‘Office RibbonX Editor’. Don’t want the same custom ribbon throughout Excel.

No funny ad-ons installed.
The Dir/folder I work from is set as ‘Trusted’ in the ‘Trusted locations’ in Excel.
This is on standalone PC. No network. No permission issues.
Running: Windows10 Pro 21H2 + Office Prof Plus 2019.


I will appreciate some input as to why this happens and how I can resolve this.
This is a serious issue for me for a project I'm working on for myself.

Thank you.


See below my customUI14.xml file and the two macros that destroys it.
Macros: Sub Import_CSV_Data_file + Sub Calculate_Stats.


```
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="HelpTab" visible="false"/>
            <tab id="c1.15050BD" label="ITTA">
                <group id="c1.151240B" label="DATA" imageMso="RecordsRefreshMenu" autoScale="true">
                    <button id="GTS.xlsm_Import_CSV_Data_file_0_15C570C" label="Import_CSV_Data_file" imageMso="SmartArtLayoutGallery" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!Import_CSV_Data_file" visible="true"/>
                    <button id="GTS.xlsm_Calculate_Stats_1_15C570C" label="Calculate_Stats" imageMso="OutlineSubtotals" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!Calculate_Stats" visible="true"/>
                </group>
                <group id="c1.1580F39" label="DATA Sheet" autoScale="true">
                    <button id="GTS.xlsm_Format_Columns_DATA_Sheet_2_15C570C" label="Format Column Layout" imageMso="HorizontalSpacingDecrease" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!Format_Columns_DATA_Sheet" visible="true"/>
                    <button id="GTS.xlsm_Sort_by_Date_and_ID_3_15C570C" label="Sort Date &amp;&amp; ID" imageMso="_3DPerspectiveDecrease" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!Sort_by_Date_and_ID" visible="true"/>
                    <button id="GTS.xlsm_Sort_by_Seq_Date_4_15C570C" label="Sort Date &amp;&amp; Sequence" imageMso="_3DPerspectiveIncrease" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!Sort_by_Seq_Date" visible="true"/>
                </group>
                <group id="c5.15B8EEA" label="SINGLE Sheet" autoScale="true">
                    <button id="GTS.xlsm_SingleSheet_Format_5_15C570C" label="Format layout &amp;&amp; Sort" imageMso="HorizontalSpacingIncrease" size="large" onAction="D:\Temp\01-Excel\GTS.xlsm!SingleSheet_Format" visible="true"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>
```


```
Sub Import_CSV_Data_file(control As IRibbonControl)

'Imports csv file in to Excel sheet.
'How? Executes an external exe file (python converted to exe) that does the import so I dont have to click that many times.

'call another macro that "cleans-up" the sheet - good to have but not a serious requirement.
    Call ALL_Del_Sort_Format_DATA_Sheet -
        
'Saves the active workbook before closing it.
    ActiveWorkbook.Save

'Waits 2 sec after previous command just in case.
    Application.Wait (Now + TimeValue("0:00:02"))

'Calls link to the external exe that does the calculations. Call exe direct does not work for some reason.
    Call Shell("explorer D:\Temp\GTS\03-Code\import_csv.dist\import_csv.lnk", vbNormalFocus)

'Closes the workbook so the exe can write to the Excel file.
    ActiveWorkbook.Close

'The exe opens the same workbook again after it's done it's job.

End Sub
```



```
Sub Calculate_Stats(control As IRibbonControl)

'Calls a Python converted to exe file that does all the formula calculations outside Excel.


'call another macro that "cleans-up" the sheet - good to have but not a serious requirement.
    Call ALL_Del_Sort_Format_DATA_Sheet -
        
    ActiveWorkbook.Save
    Application.Wait (Now + TimeValue("0:00:02"))
    Call Shell("explorer D:\Temp\GTS\03-Code\main.dist\main.lnk", vbNormalFocus)

    ActiveWorkbook.Close


End Sub
```


----------

