Trimax
Trimax

Reputation: 2473

Compile Error in Hidden Module: Module 1

I've an Addin for Excel-2010 in VBA. If I execute the code from the VBA editor it works fine. But when I execute the macro using the button in the Ribbon generated for the Addin it throws this error: Compile Error in Hidden Module: Module 1

My code:

Sub QE_eventhandler(control As IRibbonControl)
    If MsgBox("Esta acción no se podrá deshacer. ¿Desea Continuar?", vbExclamation + vbOKCancel, "Confirmar -Quitar Espacios-") = vbOK Then
        QuitaEspacios
    End If
End

Sub QuitaEspacios()
Dim celda As Range
    For Each celda In Selection
        If TypeName(celda.Value) = "String" Then
            celda.Value = Application.WorksheetFunction.Trim(celda.Value)
        End If
    Next
 End Sub

The code generated with the Custom UI Editor:

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab id="customTab" label="GARSA Tools">
                <group id="customGroup1" label="Reformateo Texto">
                    <button id="customButton3" label="Quitar Espacios" size="large" onAction="QE_eventhandler" imageMso="TextEffectTracking" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

Upvotes: 0

Views: 4990

Answers (2)

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

Check out the following links which describe a similar issue:

You receive a "Compile error in hidden module" error message when you start Word or Excel

compile error in Excel

Upvotes: 0

Rory
Rory

Reputation: 34075

You are missing an End Sub at the end of the callback - you just have End:

Sub QE_eventhandler(control As IRibbonControl)
    If MsgBox("Esta acción no se podrá deshacer. ¿Desea Continuar?", vbExclamation + vbOKCancel, "Confirmar -Quitar Espacios-") = vbOK Then
        QuitaEspacios
    End If
End Sub

Upvotes: 2

Related Questions