Excel Custom UI

Hi, I use a custom Excel.officeUI. But I’ve got an error message as following when clicking the ribbon menu in my EXE file.

“You cannot open two workbooks with the same name in Excel at the same time.”

Thanks.

You use a custom ribbon but what command did you click on?

I click the button for Macro file that I made.

And what does your macro do? Does it try to open the same workbook file?

No. my macro does not try to open the same workbook file.
I linked several macro which has following function.

  1. One of my macro is initializing the cell data with blank
  2. Save as dialogue box to save the cell data to the new worksheet
  3. Open dialogue box to read the cell values from the sheet and to write them to workbook

These macros are well working on original workbook, but all macro did not work in EXE file.

I tried to compile my workbook on the other computer, but I’ve got another error message when clicking the ribbon menu in my EXE file.

Hi,

i also have problems with my custom ui macros. with the compiled workbook the message box appears twice. this works in the normal Excel file.

Public ohneabbrechen As Boolean
Sub registrieren(control As IRibbonControl)
ohneabbrechen = True
Application.Quit
AppActivate ThisWorkbook.Windows(1).Caption
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ReturnValue As Integer

If ohneabbrechen = True Then
'ReturnValue = MsgBox(“Close Program?”, vbYesNo + vbQuestion, “Program”)

ReturnValue = MsgBox(“register in new window.” & _
vbCrLf & “” & _
vbCrLf & “Save?”, vbYesNo + vbQuestion, “Program”)

Select Case ReturnValue
Case vbYes
exportieren
Case vbNo
End Select
ThisWorkbook.Saved = True
Dim RetVal
RetVal = Shell(PathToFile(“Program.exe -enterkey”), 1)

Else

ReturnValue = MsgBox(“Save?”, vbYesNoCancel + vbQuestion, “Program”)
Select Case ReturnValue
Case vbYes
Call exportieren
Case vbCancel
Cancel = True
Case vbNo
End Select
ThisWorkbook.Saved = True

End If
End Sub

Which error this time?

Which message box because your code shows several ones?

In excel 2016, I got a error message as following.

The macro cannot be executed. Macros are not available in this workbook or all macros may not be available.

Hi,

both to register the program and to exit at normal. both times the msgbox appears twice.

And if you don’t use a custom UI, you don’t get this error message?

And you’re using which Excel version?

Unbenannt

You are right.

Hi,
I made a very simple macro as followings for the test, and link it to custom UI. It works well in excel file, but it has also same error message in complied program.

Sub UI_test_Click()
MsgBox (“Hello”)
End Sub

Error Message : The macro cannot be executed. Macros are not available in this workbook or all macros may not be available.

Do you think you could send us your custom UI file for review?

I have sent my custom UI file by e-mail. Thanks.

Got the email, thanks. We’ll study this.

Hello,

i still have problems with v2021.0 and my custom ui.
msgbox will be displayed 2 times and

RetVal = Shell(PathToFile(“customui.exe -enterkey”), 1)

doesnt work anymore.

can i send you my file for review?

Thanks

Problem with Shell(…) fixed.
No clue (yet) for the double msgbox but you could add some variable check to detect whether the msgbox was already displayed or not.