1

Topic: To get access to in Run-Time

Kind day!
Prehistory:
There is in Excel 2010 on the panel a user tab, on it set of various groups and .
Here a structure part:
[spoiler a XML file . A part certain]

<customUI xmlns = "http://schemas.microsoft.com/office/2006/01/customui" onLoad = "MyRiibonInit">
<ribbon>
<tabs>
<tab id = "CustomTab" label = "Editor" keytip = "RR">
<group id = "Group1" label = "General">
<button id = "Button11" label = to "Load" size = "normal" onAction = "SelectRs" imageMso = "FileOpenDatabase"/>
<button id = "Button12" label = to "Update" size = "normal" onAction = "RefreshRs" imageMso = "Refresh"/>
<button id = "Button13" label = to "Close" size = "normal" onAction = "CloseRs" imageMso = "GroupInkClose"/>
</group>
<group id = "Group2" label = "Design">
<button id = "Button21" label = to "Show" size = "normal" onAction = "ShowOOP" imageMso = "HeaderFooterEditHeader"/>
<button id = "Button22" label = to "Hide" size = "normal" onAction = "HideOOP" imageMso = "HeaderFooterRemoveHeaderWord"/>
<button id = "Button23" label = to "Clear" size = "normal" onAction = "ClearColor" imageMso = "FormFieldReset"/>
</group>
<group id = "Group3" label = "display Filters">
<box id = "bx_Levels" boxStyle = "vertical" visible = "true">
<checkBox id = "chb_Bak" label = "Uroven1" getPressed = "GetFiltr1" onAction = "Filtr1"/>
<checkBox id = "chb_Spec" label = "Uroven2" getPressed = "GetFiltr1" onAction = "Filtr1"/>
<checkBox id = "chb_Mag" label = "Uroven3" getPressed = "GetFiltr1" onAction = "Filtr1"/>
</box>
<box id = "bx_OtherFilters" boxStyle = "vertical">
<dropDown id = "comboBox2" label = "Forms" getSelectedItemID = "GetFiltr2ID" onAction = "Filtr2">
<item id = "cb21" label = All"/>
<item id = "cb22" label = "1"/>
<item id = "cb23" label = "2"/>
</dropDown>
<dropDown id = "comboBox3" label = "Courses" getSelectedItemID = "GetFiltr3ID" onAction = "Filtr3">
<item id = "cb31" label = All"/>
<item id = "cb32" label = "1"/>
<item id = "cb33" label = "2"/>
<item id = "cb34" label = "3"/>
<item id = "cb35" label = "4"/>
<item id = "cb36" label = "5"/>
<item id = "cb37" label = "6"/>
</dropDown>
</box>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

[/spoiler]
At book loading the global variable  from which I work is declared. But!!! In the course of operation if there is any error global variables fly.
At button click "Load" the data I can to load, but it would be desirable to update and  - in particular, to put down to all filters of value by default.
And somehow I can not understand. Whether , whether... The kick in the necessary side or the information, bribing the novelty Is necessary.
Tried to use the artful code from here . Excel takes off at line:

CopyMemory ribbon, lPointer, LenB (lPointer)

Also takes off notably, even the book then cannot neither be opened, nor to recover.
Tried CommandBars. As a result at me is Application. CommandBars ("Ribbon").Controls, in which only one  with name Ribbon. In it others  are not present sad
How to reach to  in ? Or how it to reboot and recover the link in a global variable on already loaded ?

2

Re: To get access to in Run-Time

Yes, as addition - is still here here a lot of code, but on it I any more did not suffice... I Am afraid to lose still couple of days and to achieve nothing.
If someone already understood, prompt, be so kind as smile

3

Re: To get access to in Run-Time

From the last thoughts: for loading of the data I push actually the button to Load on . I.e. I can in the same to procedure after loading working off update to update and filters.
Then there is a question - as from processing procedure for which the entering parameter is  the kontrol-button, to change value of another ?
Here, actually, procedure by the button  to Load .

Sub SelectRs (control As IRibbonControl)
Form1.Show
End Sub

From all that I wrote above, something would be desirable to make such:

Sub SelectRs (control As IRibbonControl)
' Start of the form for a choice of parameters of loading of the data
Form1.Show
' Setting of default-values
MyRibbon. Control ("chb_Bak").Value = True
End Sub

While at me here a monologue big_smile I Hope, somebody joins in the near future or I will be to by light thought mind, and the problem dares.

4

Re: To get access to in Run-Time

Well to tell... It is pleasant to talk to the good person:P
I starved the task out. And all a carelessness!
So, to return to a variable ribbon-a the pointer on itself , it is possible to use the code from here
For convenience and beauty added the separate unit containing all necessary procedures (see the link).
[spoiler procedures for reset of communication with  from the link]

Option Explicit
#If VBA7 Then
Public Declare PtrSafe Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (ByRef destination As Any, ByRef Source As Any, ByVal length As LongPtr)
#Else
Public Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (ByRef destination As Any, ByRef Source As Any, ByVal length As Long)
#End If
Public Sub InvalidateRibbon (ByRef ctrl As IRibbonControl)
RestoreRibbon
MyRibbon. Invalidate
End Sub
Sub AddNameForRibbonPointer ()
Application. Names. Add Name: = "RibbonPointer", RefersTo: = "=Ðàñïèñàíèå!$A$1", Visible: = False
End Sub
Sub RestoreRibbon ()
If MyRibbon Is Nothing Then
#If VBA7 Then
Dim lPointer As LongPtr
lPointer = CLngPtr ([RibbonPointer])
#Else
Dim lPointer As Long
lPointer = CLng ([RibbonPointer])
#End If
If lPointer <> 2029 Then _
CopyMemory ObjPtr (MyRibbon), lPointer, LenB (lPointer)
End If
End Sub

[/spoiler]
Initialization procedure  looks so:

Sub MyRibbonInit (ribbon As IRibbonUI)
Set MyRibbon = ribbon
Call AddNameForRibbonPointer
Names ("RibbonPointer").Value = ObjPtr (MyRibbon)
End Sub

The link to this procedure in XML on event onLoad:

<customUI xmlns = "http://schemas.microsoft.com/office/2006/01/customui" onLoad = "MyRibbonInit">

In the code of procedure-output agent of the button to Load wrote so:

Sub to Load (control As IRibbonControl)
' It is renewed  and we put values by default
If MyRibbon Is Nothing Then _
Call InvalidateRibbon (control)
If Not MyRibbon Is Nothing Then
Cells (4, 4) = All"
MyRibbon. InvalidateControl ("comboBox3")
End If
' (further all actions by the button)
End Sub

All thanks! Especially to the author of this code who also helped me actually smile