Refresh built-in Ribbon button after Options.DefaultHighlightColorIndex change and avoid exiting “Text Highlight Color”Changing highlighted text to a different colorExcel VBA 2010 - Command buttons stop working with multiple sheets selectedC# Word Interop - Range.HighlightColorIndex returns 999999 - Is that intended?onLoad ribbon callback fails (not firing/working) from Excel VBA .xlamSub disabled after savingHow can I restrict MS-Word to pre-defined styles but still allow inline format changesWith Block Variable not Set — Error when workbook OpenedCommunicating with Outlook 2013 add-in (Skype for Business)ActiveDocument error 4248 in Ribbon onLoad sub
How are the cards determined in an incomplete deck of many things?
When do we use "no women" instead of "no woman"?
Different past tense for various *et words
How do you manage to study and have a balance in your life at the same time?
Why is Mitch McConnell blocking nominees to the Federal Election Commission?
Calculate Landau's function
D Scale Question
How can I store milk for long periods of time?
Divide Numbers by 0
How to run a command 1 out of N times in Bash
How do I get my neighbour to stop disturbing with loud music?
Tasha's Hideous Laughter used on a deaf person?
Can a human variant take proficiency in initiative?
If the government illegally doesn't ask for article 50 extension, can parliament do it instead?
Punishment in pacifist society
How does the search space affect the speed of an ILP solver?
Displaying Time in HH:MM Format
The Justice Thought & System & its Morals?
Single vs Multiple Try Catch
Are there balance issues when allowing attack of opportunity against any creature?
How would a disabled person earn their living in a medieval-type town?
Using font to highlight a god's speech in dialogue
Function of the separated, individual solar cells on Telstar 1 and 2? Why were they "special"?
Should we run PBKDF2 for every plaintext to be protected or should we run PBKDF2 only once?
Refresh built-in Ribbon button after Options.DefaultHighlightColorIndex change and avoid exiting “Text Highlight Color”
Changing highlighted text to a different colorExcel VBA 2010 - Command buttons stop working with multiple sheets selectedC# Word Interop - Range.HighlightColorIndex returns 999999 - Is that intended?onLoad ribbon callback fails (not firing/working) from Excel VBA .xlamSub disabled after savingHow can I restrict MS-Word to pre-defined styles but still allow inline format changesWith Block Variable not Set — Error when workbook OpenedCommunicating with Outlook 2013 add-in (Skype for Business)ActiveDocument error 4248 in Ribbon onLoad sub
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
What I'm trying to get working:
- activate the Text Highlight Color command via a keybinding (not the problem)
- cycle through 5 of the Default Text Highlight Colors via the same keybinding (or just highlighting the selection, depending on selection.type checked outside the function below)
- showing the current Color in the corresponding button (built-in ribbon)
Where I'm stuck:
Sub cycleThroughSomeDefaultHighlightColorIndexOptions()
Dim zeNewColor As Long
Select Case Options.DefaultHighlightColorIndex
Case wdYellow: zeNewColor = wdBrightGreen
Case wdBrightGreen: zeNewColor = wdTurquoise
Case wdTurquoise: zeNewColor = wdPink
Case wdBlue: zeNewColor = wdRed
Case wdRed: zeNewColor = wdYellow
Case Else: zeNewColor = wdYellow
End Select
Application.Options.DefaultHighlightColorIndex = zeNewColor
End Sub
doesn't throw any error, does change the Application.Options.DefaultHighlightColorIndex,
but doesn't update/show the newly set color on the corresponding (built-in ribbon home tab) button
and just exits out of the Text Highlight Color mode.
Is there a possibility to keep it going?
If it needs to be started again: is there a better way than
dirty/interfering sendKeys to call commands like Text Highlight
Color?
Update 2019-04-03:
In the mean time i found where the IRibbonUI.InvalidateControlMso ControlID
s are listed: Office 2016 Help Files: Office Fluent User Interface Control Identifiers
So after creating a hidden custom ribbon and getting a handle for it on onLoad i could zeWdRibbon.InvalidateControlMso "TextHighlightColorPicker"
without any raised error.
But it also doesn't change anything.
Is it possible, that Microsoft just getImages the default imageMso "TextHighlightColorPicker" (yellow) without checking for Application.Options.DefaultHighlightColorIndex , or am I missing something?
vba ms-word
|
show 3 more comments
What I'm trying to get working:
- activate the Text Highlight Color command via a keybinding (not the problem)
- cycle through 5 of the Default Text Highlight Colors via the same keybinding (or just highlighting the selection, depending on selection.type checked outside the function below)
- showing the current Color in the corresponding button (built-in ribbon)
Where I'm stuck:
Sub cycleThroughSomeDefaultHighlightColorIndexOptions()
Dim zeNewColor As Long
Select Case Options.DefaultHighlightColorIndex
Case wdYellow: zeNewColor = wdBrightGreen
Case wdBrightGreen: zeNewColor = wdTurquoise
Case wdTurquoise: zeNewColor = wdPink
Case wdBlue: zeNewColor = wdRed
Case wdRed: zeNewColor = wdYellow
Case Else: zeNewColor = wdYellow
End Select
Application.Options.DefaultHighlightColorIndex = zeNewColor
End Sub
doesn't throw any error, does change the Application.Options.DefaultHighlightColorIndex,
but doesn't update/show the newly set color on the corresponding (built-in ribbon home tab) button
and just exits out of the Text Highlight Color mode.
Is there a possibility to keep it going?
If it needs to be started again: is there a better way than
dirty/interfering sendKeys to call commands like Text Highlight
Color?
Update 2019-04-03:
In the mean time i found where the IRibbonUI.InvalidateControlMso ControlID
s are listed: Office 2016 Help Files: Office Fluent User Interface Control Identifiers
So after creating a hidden custom ribbon and getting a handle for it on onLoad i could zeWdRibbon.InvalidateControlMso "TextHighlightColorPicker"
without any raised error.
But it also doesn't change anything.
Is it possible, that Microsoft just getImages the default imageMso "TextHighlightColorPicker" (yellow) without checking for Application.Options.DefaultHighlightColorIndex , or am I missing something?
vba ms-word
1
Take a look at theIRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.
– Victor K
Apr 1 at 16:02
1
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
When I tested your code snippet I gotObject Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve
– FreeSoftwareServers
Apr 4 at 2:06
1
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
Application.ScreenRefresh
would otherwise be the answer.
– HackSlash
Apr 4 at 20:48
|
show 3 more comments
What I'm trying to get working:
- activate the Text Highlight Color command via a keybinding (not the problem)
- cycle through 5 of the Default Text Highlight Colors via the same keybinding (or just highlighting the selection, depending on selection.type checked outside the function below)
- showing the current Color in the corresponding button (built-in ribbon)
Where I'm stuck:
Sub cycleThroughSomeDefaultHighlightColorIndexOptions()
Dim zeNewColor As Long
Select Case Options.DefaultHighlightColorIndex
Case wdYellow: zeNewColor = wdBrightGreen
Case wdBrightGreen: zeNewColor = wdTurquoise
Case wdTurquoise: zeNewColor = wdPink
Case wdBlue: zeNewColor = wdRed
Case wdRed: zeNewColor = wdYellow
Case Else: zeNewColor = wdYellow
End Select
Application.Options.DefaultHighlightColorIndex = zeNewColor
End Sub
doesn't throw any error, does change the Application.Options.DefaultHighlightColorIndex,
but doesn't update/show the newly set color on the corresponding (built-in ribbon home tab) button
and just exits out of the Text Highlight Color mode.
Is there a possibility to keep it going?
If it needs to be started again: is there a better way than
dirty/interfering sendKeys to call commands like Text Highlight
Color?
Update 2019-04-03:
In the mean time i found where the IRibbonUI.InvalidateControlMso ControlID
s are listed: Office 2016 Help Files: Office Fluent User Interface Control Identifiers
So after creating a hidden custom ribbon and getting a handle for it on onLoad i could zeWdRibbon.InvalidateControlMso "TextHighlightColorPicker"
without any raised error.
But it also doesn't change anything.
Is it possible, that Microsoft just getImages the default imageMso "TextHighlightColorPicker" (yellow) without checking for Application.Options.DefaultHighlightColorIndex , or am I missing something?
vba ms-word
What I'm trying to get working:
- activate the Text Highlight Color command via a keybinding (not the problem)
- cycle through 5 of the Default Text Highlight Colors via the same keybinding (or just highlighting the selection, depending on selection.type checked outside the function below)
- showing the current Color in the corresponding button (built-in ribbon)
Where I'm stuck:
Sub cycleThroughSomeDefaultHighlightColorIndexOptions()
Dim zeNewColor As Long
Select Case Options.DefaultHighlightColorIndex
Case wdYellow: zeNewColor = wdBrightGreen
Case wdBrightGreen: zeNewColor = wdTurquoise
Case wdTurquoise: zeNewColor = wdPink
Case wdBlue: zeNewColor = wdRed
Case wdRed: zeNewColor = wdYellow
Case Else: zeNewColor = wdYellow
End Select
Application.Options.DefaultHighlightColorIndex = zeNewColor
End Sub
doesn't throw any error, does change the Application.Options.DefaultHighlightColorIndex,
but doesn't update/show the newly set color on the corresponding (built-in ribbon home tab) button
and just exits out of the Text Highlight Color mode.
Is there a possibility to keep it going?
If it needs to be started again: is there a better way than
dirty/interfering sendKeys to call commands like Text Highlight
Color?
Update 2019-04-03:
In the mean time i found where the IRibbonUI.InvalidateControlMso ControlID
s are listed: Office 2016 Help Files: Office Fluent User Interface Control Identifiers
So after creating a hidden custom ribbon and getting a handle for it on onLoad i could zeWdRibbon.InvalidateControlMso "TextHighlightColorPicker"
without any raised error.
But it also doesn't change anything.
Is it possible, that Microsoft just getImages the default imageMso "TextHighlightColorPicker" (yellow) without checking for Application.Options.DefaultHighlightColorIndex , or am I missing something?
vba ms-word
vba ms-word
edited Apr 3 at 21:38
blub
asked Mar 28 at 0:53
blubblub
9366 silver badges16 bronze badges
9366 silver badges16 bronze badges
1
Take a look at theIRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.
– Victor K
Apr 1 at 16:02
1
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
When I tested your code snippet I gotObject Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve
– FreeSoftwareServers
Apr 4 at 2:06
1
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
Application.ScreenRefresh
would otherwise be the answer.
– HackSlash
Apr 4 at 20:48
|
show 3 more comments
1
Take a look at theIRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.
– Victor K
Apr 1 at 16:02
1
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
When I tested your code snippet I gotObject Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve
– FreeSoftwareServers
Apr 4 at 2:06
1
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
Application.ScreenRefresh
would otherwise be the answer.
– HackSlash
Apr 4 at 20:48
1
1
Take a look at the
IRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.– Victor K
Apr 1 at 16:02
Take a look at the
IRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.– Victor K
Apr 1 at 16:02
1
1
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
When I tested your code snippet I got
Object Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve– FreeSoftwareServers
Apr 4 at 2:06
When I tested your code snippet I got
Object Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve– FreeSoftwareServers
Apr 4 at 2:06
1
1
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
Application.ScreenRefresh
would otherwise be the answer.– HackSlash
Apr 4 at 20:48
Application.ScreenRefresh
would otherwise be the answer.– HackSlash
Apr 4 at 20:48
|
show 3 more comments
1 Answer
1
active
oldest
votes
I do something like that, each time gRibbon.Invalidate
#If VBA7 Then
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#Else
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Public gRibbon As IRibbonUI
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
Call CopyMemory(objRibbon, lRibbonPointer, LenB(lRibbonPointer))
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
Public Sub OnRibbonLoad(ribbon As IRibbonUI)
Set gRibbon = ribbon
'SAVE SETTINGS TO REGISTRY
SaveSetting "POP", "RIBBON", "ribbonPointer", ObjPtr(gRibbon)
End Sub
Public Sub OnActionButton(control As IRibbonControl)
If gRibbon Is Nothing Then
Set gRibbon = GetRibbon(GetSetting("POP", "RIBBON", "ribbonPointer"))
End If
On Error Resume Next
gRibbon.Invalidate
On Error GoTo 0
End Sub
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388617%2frefresh-built-in-ribbon-button-after-options-defaulthighlightcolorindex-change-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I do something like that, each time gRibbon.Invalidate
#If VBA7 Then
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#Else
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Public gRibbon As IRibbonUI
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
Call CopyMemory(objRibbon, lRibbonPointer, LenB(lRibbonPointer))
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
Public Sub OnRibbonLoad(ribbon As IRibbonUI)
Set gRibbon = ribbon
'SAVE SETTINGS TO REGISTRY
SaveSetting "POP", "RIBBON", "ribbonPointer", ObjPtr(gRibbon)
End Sub
Public Sub OnActionButton(control As IRibbonControl)
If gRibbon Is Nothing Then
Set gRibbon = GetRibbon(GetSetting("POP", "RIBBON", "ribbonPointer"))
End If
On Error Resume Next
gRibbon.Invalidate
On Error GoTo 0
End Sub
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
add a comment |
I do something like that, each time gRibbon.Invalidate
#If VBA7 Then
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#Else
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Public gRibbon As IRibbonUI
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
Call CopyMemory(objRibbon, lRibbonPointer, LenB(lRibbonPointer))
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
Public Sub OnRibbonLoad(ribbon As IRibbonUI)
Set gRibbon = ribbon
'SAVE SETTINGS TO REGISTRY
SaveSetting "POP", "RIBBON", "ribbonPointer", ObjPtr(gRibbon)
End Sub
Public Sub OnActionButton(control As IRibbonControl)
If gRibbon Is Nothing Then
Set gRibbon = GetRibbon(GetSetting("POP", "RIBBON", "ribbonPointer"))
End If
On Error Resume Next
gRibbon.Invalidate
On Error GoTo 0
End Sub
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
add a comment |
I do something like that, each time gRibbon.Invalidate
#If VBA7 Then
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#Else
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Public gRibbon As IRibbonUI
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
Call CopyMemory(objRibbon, lRibbonPointer, LenB(lRibbonPointer))
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
Public Sub OnRibbonLoad(ribbon As IRibbonUI)
Set gRibbon = ribbon
'SAVE SETTINGS TO REGISTRY
SaveSetting "POP", "RIBBON", "ribbonPointer", ObjPtr(gRibbon)
End Sub
Public Sub OnActionButton(control As IRibbonControl)
If gRibbon Is Nothing Then
Set gRibbon = GetRibbon(GetSetting("POP", "RIBBON", "ribbonPointer"))
End If
On Error Resume Next
gRibbon.Invalidate
On Error GoTo 0
End Sub
I do something like that, each time gRibbon.Invalidate
#If VBA7 Then
Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#Else
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Public gRibbon As IRibbonUI
#If VBA7 Then
Function GetRibbon(ByVal lRibbonPointer As LongPtr) As Object
#Else
Function GetRibbon(ByVal lRibbonPointer As Long) As Object
#End If
Dim objRibbon As Object
Call CopyMemory(objRibbon, lRibbonPointer, LenB(lRibbonPointer))
Set GetRibbon = objRibbon
Set objRibbon = Nothing
End Function
Public Sub OnRibbonLoad(ribbon As IRibbonUI)
Set gRibbon = ribbon
'SAVE SETTINGS TO REGISTRY
SaveSetting "POP", "RIBBON", "ribbonPointer", ObjPtr(gRibbon)
End Sub
Public Sub OnActionButton(control As IRibbonControl)
If gRibbon Is Nothing Then
Set gRibbon = GetRibbon(GetSetting("POP", "RIBBON", "ribbonPointer"))
End If
On Error Resume Next
gRibbon.Invalidate
On Error GoTo 0
End Sub
answered Apr 5 at 8:28
Dmitrij HolkinDmitrij Holkin
2,0043 gold badges21 silver badges61 bronze badges
2,0043 gold badges21 silver badges61 bronze badges
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
add a comment |
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
This is great for keeping the public ribbon object, which would be set to nothing after an unhandled error, but my problem here seems to be, that there is a second, undocumented kind of Application.Options.DefaultHighlightColorIndex.
– blub
Apr 6 at 16:05
Sets or returns the colour used to highlight text formatted with the Highlight button.
Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Sets or returns the colour used to highlight text formatted with the Highlight button.
Application.Options.DefaultHighlightColorIndex = wdColorIndex.wdGreen
– Dmitrij Holkin
Apr 6 at 21:23
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
Application.Options.DefaultHighlightColorIndex is completely ignored by iRibbonUI.invalidate AND by Application.CommandBars.ExecuteMso "TextHighlightColorPicker" (and the corresponding button) so there has to be a different property that I didn't find until now.
– blub
Apr 7 at 13:16
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
try look here bettersolutions.com/word/options/vba-code.htm
– Dmitrij Holkin
Apr 7 at 13:48
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
@blub if this GetRibbon function actually gives you a handle on the current ribbon then you should be able to modify the ribbon directly.
– HackSlash
Apr 8 at 15:10
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388617%2frefresh-built-in-ribbon-button-after-options-defaulthighlightcolorindex-change-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Take a look at the
IRibbonUI.Invaludate
method - it might be what you are looking for if you are trying to refresh the ribbon.– Victor K
Apr 1 at 16:02
1
I believe you can find your answer in this article along with VBA code (run the form) wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.php
– user2261597
Apr 2 at 14:30
When I tested your code snippet I got
Object Required
. Please post everything you need to reproduce the issue. --> stackoverflow.com/help/mcve– FreeSoftwareServers
Apr 4 at 2:06
1
It's not just the GUI that is displaying the old color. If I change it and then click the button then the value is changed back to the default of 7. So it seems that the ribbon overwrites the value with something it has stored elsewhere.
– HackSlash
Apr 4 at 20:44
Application.ScreenRefresh
would otherwise be the answer.– HackSlash
Apr 4 at 20:48