• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Custum ui excel

Status
Niet open voor verdere reacties.

longron

Gebruiker
Lid geworden
2 apr 2007
Berichten
372
Beste alle,

hoe kan ik in het meegeleverde excel bestand het standaard menu "Bestand" geheel verwijderen zodat ik alleen mijn eigen menu over hoe?

En een tweede vraag: Kan ik zoals vroeger wel kon ook de sluitkruisjes rechtbovenin geheel verwijderen?
Inactief maken weet ik.

Thanks,

Fijne dag.

groetjes
Ronald
 

Bijlagen

sluitkruisjes rechtbovenin geheel verwijderen?
Kan blokkeren.


Vraag 1
Code:
Sub HideRibbon()
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
End Sub

Sub ShowRibbon()
    Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",True)"
End Sub
Vraag2
Code:
This Workbook							
Private Sub Workbook_Open()							
DisableActiveDialogMenuControls 'Zie Module Minimize en close button uitschakelen of verbergen							
End Sub							
							
In module							
Option Explicit							
							
Declare PtrSafe Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, ByVal _							
    bRevert As Long) As Long							
Declare PtrSafe Function DeleteMenu Lib "User32" (ByVal hMenu As Long, ByVal _							
    nPosition As Long, ByVal wFlags As Long) As Long							
Declare PtrSafe Function FindWindowA Lib "User32" (ByVal lpClassName As String, _							
ByVal lpWindowName As String) As Long							
							
Const MF_BYPOSITION As Long = &H400							
Const mlNUM_SYS_MENU_ITEMS As Long = 7 'min, max & close							
'Const mlNUM_SYS_MENU_ITEMS As Long = 6 'min & max							
							
Sub DisableActiveDialogMenuControls()							
    Dim DialogCaption As String							
    Dim lHandle As Long, lcount As Long							
    On Error Resume Next							
    DialogCaption = Application.Caption							
    DialogCaption = DialogCaption & vbNullChar							
    lHandle = FindWindowA(vbNullString, DialogCaption)							
    If lHandle <> 0 Then							
        For lcount = 1 To mlNUM_SYS_MENU_ITEMS							
            DeleteMenu GetSystemMenu(lHandle, False), 0, MF_BYPOSITION							
        Next lcount							
    End If							
End Sub							
							
Sub EnableActiveDialogMenuControls()							
    Dim lHandle As Long							
    Dim DialogCaption As String							
    On Error Resume Next							
    DialogCaption = Application.Caption							
    DialogCaption = DialogCaption & vbNullChar							
    lHandle = FindWindowA(vbNullString, DialogCaption)							
    GetSystemMenu lHandle, True							
End Sub


Ik gebruik Office 2019
(PtrSafe vanaf office 2016)
 

Bijlagen

Laatst bewerkt:
Kleine correctie.
PtrSave is voor de 64-bit edities van Office.
Zou het mogelijk zijn beiden in een macro met en zonder PrSave ? Compileerfout!
Declare PtrSafe Function GetSystemMenu ……..
Else
Declare Function GetSystemMenu ……..
 
Dat kan met een compiler directive:
Code:
#If Win64 Then
    [COLOR="#008000"]'64-bit Declaraties[/COLOR]
#Else
    [COLOR="#008000"]'32-bit Declaraties[/COLOR]
#EndIf
 
@All.

dank voor de reacties.

Echter als ik hidden gebruik ben ik ook mijn eigen menu kwijt en die wil ik juist houden.
 
@Edmoor.

Welke declaratie zou ik moeten gebruiken als ik 32bit wil gebruiken?
Bedoel je?


Private Const MF_BYPOSITION As Long = &H400
Private Const MF_BYCOMMAND As Long = &H0
Private Const mlNUM_SYS_MENU_ITEMS As Long = 9
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Dit is voor mij toch hogere wiskunde :O
 
Wat je hebt staan is voor 32-bit Office.
 
Dat zal het dit moeten worden?

Thanks


#If Win64 Then
'64-bit Declaraties
Declare PtrSafe Function GetSystemMenu Lib "User32" (ByVal hwnd As Long, ByVal _
bRevert As Long) As Long
Declare PtrSafe Function DeleteMenu Lib "User32" (ByVal hMenu As Long, ByVal _
nPosition As Long, ByVal wFlags As Long) As Long
Declare PtrSafe Function FindWindowA Lib "User32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Const MF_BYPOSITION As Long = &H400
Const mlNUM_SYS_MENU_ITEMS As Long = 7 'min, max & close
'Const mlNUM_SYS_MENU_ITEMS As Long = 6 'min & max
#Else
'32-bit Declaraties
Private Const MF_BYPOSITION As Long = &H400
Private Const MF_BYCOMMAND As Long = &H0
Private Const mlNUM_SYS_MENU_ITEMS As Long = 9
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

#EndIf
 
Ik zou het zo doen:
Code:
#If Win64 Then
    '64-bit Declaraties
    Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    Declare PtrSafe Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Declare PtrSafe Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#Else
    '32-bit Declaraties
    Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
    Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
    Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
#End If

Const MF_BYPOSITION As Long = &H400
Const MF_BYCOMMAND As Long = &H0
Const mlNUM_SYS_MENU_ITEMS As Long = 9
 
Laatst bewerkt:
Top,

thanks,

dat ziet er veel beter uit,

Had je nog een advies mbt het menu?

als ik hidden gebruik ben ik mijn eigen menu ook kwijt maar dat wil ik niet.

Denk dat het met de CustomUIEditor moet doen.
 
CustomUI gebruik ik regelmatig, maar ik heb nog nooit gekeken of het mogelijk is het standaard Excel menu compleet te vervangen door een eigen ribbon.
Kijk eens of je hier wat mee kunt:
https://www.rondebruin.nl/win/s2/win016.htm
 
:( helaas kan je niet het menu "Bestand" weghalen.
Maar natuurlijk wel in inhoud. Beter iets dan niet.

Thanks All.

Ronald
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan