hermanlaksko
Programmer
I am trying to run the belov code and the Ribbon is created but will not load or show if selected on a given form
Sub LetItRip()
Dim RibbonXml As String, A, B, RibName, Rib As Office.IRibbonUI
RibName = "MenuMainRib"
A = Array("&Adgang", "&Skift bruger", "Skift database", "Afslut program", _
"&Firma F3", "&Brugere", "&Grupper", "&Aktiviteter &", "& Niveauer", _
"&Centre", "&Vagtkategorier", "&Plantyper", "Outlook", "Skoleoversigt F4", "&Planoversigt F5", "&Vagtoversigt F6", "&Aktivitetsoversigt F7", _
"National planlægning", "&Luk alle vinduer F12", "F-Taster", "&Versions info", "&Om Studievalg Danmark") 'Button names
B = Array("=OpenAny('UserAdmin')", "=OpenAny('Login',False,False)", "=OpenAny('SkiftDatabase',True,false,True)", "=AslutPrg()", _
"=F3()", "=OpenAny('UserOverview')", "=OpenAny('Grupper')", "=OpenAny('ArrangementListe')", "=OpenAny('Centre')", "=OpenAny('VagtKategori')", "=OpenAny('PTyper')", _
"", "=F4()", "=F5()", "=F6()", "=F7()", "=CloseAllForms("")", "", "=OpenAny('Z_VerHist')", "=OpenAny('About')")
RibbonXml = "<?xml version='1.0' encoding='UTF-8'?>"
RibbonXml = RibbonXml + "<mso:customUI xmlns:mso=' OnLoad='OnLoad' >"
'RibbonXml = "<mso:customUI xmlns:x1=' xmlns:mso=' onLoad='InitNewRib'>"
'RibbonXml = "<customUI xmlns=' >"
'RibbonXml = RibbonXml + "<ribbon startFromScratch='true'>"
'Application.LoadCustomUI RibName, RibbonXml
RibbonXml = RibbonXml + "<mso:ribbon><mso:tabs><mso:tab id='Tools' label='" & RibName & "' insertBeforeQ='mso:TabFormat' >"
'Knapper i grp 1 - Filer
RibbonXml = RibbonXml + "<mso:group id='Filer' label='Brugere / database' autoScale='true' >"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup1' label='" & A(0) & "' screentip='Slet personer ikke brugt' supertip='1' onAction='" & B(0) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup2' label='" & A(1) & "' screentip='Gem Publish og Luk' onAction='" & B(1) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup3' label='" & A(2) & "' screentip='Reset' onAction='" & B(2) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
'Knapper i grp 2 - Opsætning
RibbonXml = RibbonXml + "<mso:group id='Opset' label='Indstillinger'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup4' label='" & A(3) & "' screentip='Reset' onAction='" & B(3) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup5' label='" & A(4) & "' screentip='Reset' onAction='" & B(4) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup6' label='" & A(5) & "' screentip='Reset' onAction='" & B(5) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup7' label='" & A(6) & "' screentip='Reset' onAction='" & B(6) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup8' label='" & A(7) & "' screentip='Reset' onAction='" & B(7) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup9' label='" & A(8) & "' screentip='Reset' onAction='" & B(8) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup10' label='" & A(9) & "' screentip='Reset' onAction='" & B(9) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup11' label='" & A(10) & "' screentip='Reset' onAction='" & B(10) & "'/>"
RibbonXml = RibbonXml + "<mso:group id='Oversigter' label='Datalister' autoScale='true'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup12' label='" & A(11) & "' screentip='Institutionsoversigt' onAction='" & A(11) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup13' label='" & A(12) & "' screentip='Udskriv tilsyn til PDF' onAction='" & A(12) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup14' label='" & A(13) & "' screentip='Vis udskrift for ressource' onAction='" & A(13) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup15' imageMso='MicrosoftVisualFoxPro' screentip='Fox' onAction=''" & A(14) & "''/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup16' imageMso='SlideNew' screentip='2' onAction='" & A(15) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
'Knapper i grp 2
RibbonXml = RibbonXml + "<mso:group id='Hjælp' label='ABC' autoScale='true'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup17' label='" & A(16) & "' screentip='Udskriv planer for tilsyn' onAction='" & A(16) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup18' label='" & A(17) & "' screentip='Udskriv tilsyn til PDF' onAction='" & A(17) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup19' label='" & A(18) & "' screentip='Vis udskrift for ressource' onAction='" & A(18) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup20' imageMso='MicrosoftVisualFoxPro' screentip='Fox' onAction='" & A(19) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
RibbonXml = RibbonXml + "</mso:tab></mso:tabs></mso:ribbon></mso:customUI>"
Application.LoadCustomUI RibName, RibbonXml
Rib.ActivateTab RibName
ExitHere:
Exit Sub
Fail:
MsgBox Err.Description, , SD
Resume ExitHere
End Sub
I know that would be an easyer task to use a table witch I will do later but for now I use arrays, the thing works and it does create the ribbon but the ribbon will not show and the Sub gives an error on the last line (Rib.ActivateTab RibName) as the Rib is never set, but how to set the Rib variable I am unsure.
So 2 questions.:
1. Why will it not show?
2. Is this all wrong and shoud I use a different approch?
HELP please
Herman
Say no to macros
Sub LetItRip()
Dim RibbonXml As String, A, B, RibName, Rib As Office.IRibbonUI
RibName = "MenuMainRib"
A = Array("&Adgang", "&Skift bruger", "Skift database", "Afslut program", _
"&Firma F3", "&Brugere", "&Grupper", "&Aktiviteter &", "& Niveauer", _
"&Centre", "&Vagtkategorier", "&Plantyper", "Outlook", "Skoleoversigt F4", "&Planoversigt F5", "&Vagtoversigt F6", "&Aktivitetsoversigt F7", _
"National planlægning", "&Luk alle vinduer F12", "F-Taster", "&Versions info", "&Om Studievalg Danmark") 'Button names
B = Array("=OpenAny('UserAdmin')", "=OpenAny('Login',False,False)", "=OpenAny('SkiftDatabase',True,false,True)", "=AslutPrg()", _
"=F3()", "=OpenAny('UserOverview')", "=OpenAny('Grupper')", "=OpenAny('ArrangementListe')", "=OpenAny('Centre')", "=OpenAny('VagtKategori')", "=OpenAny('PTyper')", _
"", "=F4()", "=F5()", "=F6()", "=F7()", "=CloseAllForms("")", "", "=OpenAny('Z_VerHist')", "=OpenAny('About')")
RibbonXml = "<?xml version='1.0' encoding='UTF-8'?>"
RibbonXml = RibbonXml + "<mso:customUI xmlns:mso=' OnLoad='OnLoad' >"
'RibbonXml = "<mso:customUI xmlns:x1=' xmlns:mso=' onLoad='InitNewRib'>"
'RibbonXml = "<customUI xmlns=' >"
'RibbonXml = RibbonXml + "<ribbon startFromScratch='true'>"
'Application.LoadCustomUI RibName, RibbonXml
RibbonXml = RibbonXml + "<mso:ribbon><mso:tabs><mso:tab id='Tools' label='" & RibName & "' insertBeforeQ='mso:TabFormat' >"
'Knapper i grp 1 - Filer
RibbonXml = RibbonXml + "<mso:group id='Filer' label='Brugere / database' autoScale='true' >"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup1' label='" & A(0) & "' screentip='Slet personer ikke brugt' supertip='1' onAction='" & B(0) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup2' label='" & A(1) & "' screentip='Gem Publish og Luk' onAction='" & B(1) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup3' label='" & A(2) & "' screentip='Reset' onAction='" & B(2) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
'Knapper i grp 2 - Opsætning
RibbonXml = RibbonXml + "<mso:group id='Opset' label='Indstillinger'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup4' label='" & A(3) & "' screentip='Reset' onAction='" & B(3) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup5' label='" & A(4) & "' screentip='Reset' onAction='" & B(4) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup6' label='" & A(5) & "' screentip='Reset' onAction='" & B(5) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup7' label='" & A(6) & "' screentip='Reset' onAction='" & B(6) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup8' label='" & A(7) & "' screentip='Reset' onAction='" & B(7) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup9' label='" & A(8) & "' screentip='Reset' onAction='" & B(8) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup10' label='" & A(9) & "' screentip='Reset' onAction='" & B(9) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup11' label='" & A(10) & "' screentip='Reset' onAction='" & B(10) & "'/>"
RibbonXml = RibbonXml + "<mso:group id='Oversigter' label='Datalister' autoScale='true'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup12' label='" & A(11) & "' screentip='Institutionsoversigt' onAction='" & A(11) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup13' label='" & A(12) & "' screentip='Udskriv tilsyn til PDF' onAction='" & A(12) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup14' label='" & A(13) & "' screentip='Vis udskrift for ressource' onAction='" & A(13) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup15' imageMso='MicrosoftVisualFoxPro' screentip='Fox' onAction=''" & A(14) & "''/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup16' imageMso='SlideNew' screentip='2' onAction='" & A(15) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
'Knapper i grp 2
RibbonXml = RibbonXml + "<mso:group id='Hjælp' label='ABC' autoScale='true'>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup17' label='" & A(16) & "' screentip='Udskriv planer for tilsyn' onAction='" & A(16) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup18' label='" & A(17) & "' screentip='Udskriv tilsyn til PDF' onAction='" & A(17) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup19' label='" & A(18) & "' screentip='Vis udskrift for ressource' onAction='" & A(18) & "'/>"
RibbonXml = RibbonXml + " <mso:button id='ButtonGroup20' imageMso='MicrosoftVisualFoxPro' screentip='Fox' onAction='" & A(19) & "'/>"
RibbonXml = RibbonXml + "</mso:group>"
RibbonXml = RibbonXml + "</mso:tab></mso:tabs></mso:ribbon></mso:customUI>"
Application.LoadCustomUI RibName, RibbonXml
Rib.ActivateTab RibName
ExitHere:
Exit Sub
Fail:
MsgBox Err.Description, , SD
Resume ExitHere
End Sub
I know that would be an easyer task to use a table witch I will do later but for now I use arrays, the thing works and it does create the ribbon but the ribbon will not show and the Sub gives an error on the last line (Rib.ActivateTab RibName) as the Rib is never set, but how to set the Rib variable I am unsure.
So 2 questions.:
1. Why will it not show?
2. Is this all wrong and shoud I use a different approch?
HELP please
Herman
Say no to macros