Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

XML for Comment Button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ldjarmin - 27 Feb 2008 14:16 GMT
Alright, so here's what I'm looking at.

I'm making a custom tab on the Ribbon/Fluent UI in Word 2007.  I've got that
part down.  It'll be populated with a series of buttons and/or drop down
boxes, each of which is set to insert a prescripted comment into the document
at where the cursor is.  How do I do this?  I know how to make a button which
inserts some text into the document, but not how to make the button (or
alternatively choosing an option from a drop down list or whatever) insert a
comment.

Also, on a related note, is there a way to make this user customizable?  By
that I mean, have like a Word document or Excel file that has all the names
of the comments and the comment text and the user can change the text of a
comment or title?

Thanks!
Tony Jollans - 27 Feb 2008 19:22 GMT
This has nothing directly to do with the ribbon. Your button that inserts
text has a callback that can run arbitrary VBA code - just make it insert a
comment instead ...

   Selection.Comments.Add Selection.Range, "The Moon's a Balloon"

You can make the whole thing as sophisticated as you like - it just depends
how much effort you want to put into it. A lookup to another Word document
or an Excel table or a text file or registry entries or ... is certainly
possible. I don't know off the top of my head how to fill in a dropdown in
the ribbon but it must be possible - or your ribbon button could bring up a
userform from which a choice could be made or maintenance of the cross
reference list could be done or ... the world's your lobster.

Signature

Enjoy,
Tony

> Alright, so here's what I'm looking at.
>
[quoted text clipped - 18 lines]
>
> Thanks!
Greg Maxey - 27 Feb 2008 20:44 GMT
On Feb 27, 2:22 pm, "Tony Jollans" <My forename at my surname dot com>
wrote:
> This has nothing directly to do with the ribbon. Your button that inserts
> text has a callback that can run arbitrary VBA code - just make it insert a
[quoted text clipped - 38 lines]
>
> - Show quoted text -

I am not sure that I understand you complete objective, but continuing
with what Tony suggested, you only need the XML to define the Tab, the
Group, and ID the dropdown.  You need to have an OnAction macro
defined for the DropDown.  The XML might look something like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="Onload">
 <ribbon>
   <tabs>
      <tab id="CustomTab" label="My Tab">
       <group id="SampleGroup" label="Sample Group">
          <dropDown id="DD1" label="My DropDownBox" getItemCount=
"GetItemCount" getItemLabel="GetItemLabel" onAction="MyDDMacro">
          </dropDown>
       </group>
     </tab>
   </tabs>
 </ribbon>
</customUI>

Then in the VBA project module you can define how many dropdown items
there needs to be, what their labels are, and what happens when each
one is clicked:

Option Explicit
Public myRibbon As IRibbonUI

Sub Onload(ribbon As IRibbonUI)
Set myRibbon = ribbon
End Sub

Sub MyDDMacro(ByVal control As IRibbonControl, selectedId As String,
selectedIndex As Integer)
Select Case selectedIndex
 Case Is = 0
   Selection.Comments.Add Selection.Range, "The Moon's a Balloon"
 Case Is = 1
   Selection.Comments.Add Selection.Range, "Tony is a master of the
array"
Case Is = 2
   Selection.Comments.Add Selection.Range, "NG courtesy cop need not
reply"
End Select
End Sub

Sub GetItemLabel(ByVal control As IRibbonControl, Index As Integer,
ByRef label)
Select Case control.ID
 Case "DD1"
   Select Case Index
     Case Is = 0
       label = "Moon comment"
     Case Is = 1
       label = "Tony Comment"
     Case Is = 2
       label = "Courtesy cop comment"
   End Select
End Select
End Sub

Sub GetItemCount(ByVal control As IRibbonControl, ByRef count)
Select Case control.ID
 Case "DD1"
   count = 3
 Case Else
   'Do Nothing
End Select
End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.