Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Disabling custom buttons on ribbon unless file is open
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Greg Maxey, post: 5884278"] EKH, It seems to work (I have done very limited testing). In the template create a Class module named "appClass" and paste in this code: Option Explicit Public WithEvents oApp As Word.Application Private Sub oApp_DocumentChange() bEnable = False myRibbon.Invalidate If Documents.Count > 0 Then bEnable = True End Sub In your ribbon control project module (I call my RibCon) paste in this code: Option Explicit Public bEnable As Boolean Public myRibbon As IRibbonUI Sub OnLoad(ribbon As IRibbonUI) 'Create a ribbon instance Set myRibbon = ribbon End Sub Sub BtnOnAction(control As IRibbonControl) MsgBox control.ID & " depressed" End Sub Sub GetEnabled(control As IRibbonControl, ByRef returnedVal) If bEnable Then returnedVal = "True" End Sub In a standard project module paste in this code: Option Explicit Dim oAppClass As New appClass Sub AutoExec() Set oAppClass.oApp = Word.Application End Sub For the test I created a simple ribbon interface template and stored it in the Word Startup folder. Here is the RibbonX for the test file: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <customUI xmlns="[URL]http://schemas.microsoft.com/office/2006/01/customui[/URL]" onLoad="RibCon.Onload"> <ribbon> <tabs> <tab id="TabTest" label="Test Tab"> <group id="Grp1" label="Test Group"> <button id="Btn1" label="Button 1" getEnabled="RibCon.GetEnabled" onAction="RibCon.BtnOnAction"/> <button id="Btn2" label="Button 2" onAction="RibCon.BtnOnAction"/> </group> </tab> </tabs> </ribbon> </customUI> [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Disabling custom buttons on ribbon unless file is open
Top