none
How do I display the contents of a MailMergeMergeFieldInsertMenu splitButton in the Word 2007 Ribbon RRS feed

  • Question

  • Originally I set out to display a 'supertip' as shown below for the 'Insert Merge Fields' Button on the 'Mailings' Tab of the Word 2007 Ribbon.

    As you can see, I succeeded - sort of.  The only problem I have is that when I click on the bottom half of the splitButton control I get a totally empty list.  It does not display the Fields in my Mail-Merge Data Source.  Yet when I click on the top half of the Control, I get the correct 'Insert Merge Field' Dialog, with all the Merge Field listed correctly.  What am I missing:

    This is my XML in full:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" 
    	onLoad="CustomUI_OnLoad" >
    
    	<commands>
    		<command idMso="MailMergeCreateList" onAction="EnableOrDisable_On2itMergeToEmail_Group" />
    		<command idMso="MailMergeRecepientsUseExistingList" onAction="EnableOrDisable_On2itMergeToEmail_Group" />
    		<command idMso="MailMergeRecepientsUseOutlookContacts" onAction="EnableOrDisable_On2itMergeToEmail_Group" /> 
    		<command idMso="MailMergeClearMergeType" onAction="MailMergeClearMergeType_onAction" />
    	</commands>
    
    	<ribbon startFromScratch="false">
    		<tabs>
    			<tab idMso="TabMailings" >
    
    				<group idMso="GroupMailMergeStart" visible="false" />
    				<group idMso="GroupEnvelopeLabelCreate" visible="false" />
    				<group idMso="GroupMailMergeFinish"	visible="false" />
    
    				<group 
    					id="GroupOn2itMailMergeStart" 
    					label="Recipients List"
    					insertBeforeMso="GroupMailMergeWriteInsertFields" 
    					visible="true" >
    					<menu 
    						id="On2itMailMergeSelectRecipients" 
    						label="Add, Edit or Remove"
    						size="large" 
    						imageMso="MailMergeSelectRecipients"
    						visible="true" 
    						screentip="Add, Edit or Remove - Recipients List                                                 ." 
    						supertip="If you originated your 'Merge to E-mail' from 'On2it-GEM' a list of Recipients will have been already added for you.&#13;&#13;If not, you can:&#13;    - type you own list, &#13;    - use your Outlook contacts, or &#13;    - connect to a database.  &#13;&#13;EDIT allows you to specify who you wish to send E-mails to and even change the contents of the Mail-Merge data fields.  &#13;&#13;REMOVE your Recipients List will revert your Document to a 'Normal Word Document'by removing it's Mail-Merge Data Source.  " >
    						<button 
    							idMso="MailMergeCreateList" 
    							label="Type New List..." 
    							screentip="Type New List                                                                   ." 
    							supertip="Enables you to create your own Recipients List from scratch.  " />
    						<button 
    							idMso="MailMergeRecepientsUseExistingList" 
    							label="Use Existing List..." 
    							screentip="Use Existing List                                                               ." 
    							supertip="Enables you to use an existing Recipients List like an:&#13;    - Excel Spreadsheet,:&#13;    - Access Database,:&#13;    - or whatever ...  " />
    						<button 
    							idMso="MailMergeRecepientsUseOutlookContacts"  
    							label="Select from Outlook Contacts..." 
    							screentip="Select from Outlook Contacts                                                    ." 
    							supertip="Enables you to select which of your Outlook Contacts this E-mail should be sent to.  " />
    						<button 
    							idMso="MailMergeRecipientsEditList" 
    							label="EDIT Recipients List..." 
    							screentip="EDIT Recipients List                                                            ." 
    							supertip="Enables you to&#13;    - stop the E-mail from being sent to some Recipients,&#13;    - change the contents of your Merge Data Fields, and&#13;    - even add new Recipients, if you wish to. " />
    						<toggleButton 
    							idMso="MailMergeClearMergeType"
    							label="REMOVE Recipients List..." 
    							screentip="REMOVE Recipients List                                                          ." 
    							supertip="This will revert your Document to a 'Normal Word Document', by removing its Mail-Merge Data Source.  &#13;&#13;There is however no real need to do so, as you can still send E-mails using the 'Send a Copy' Button, without doing a 'Merge to E-mail', if you wish.  " />
    					</menu>
    				</group>
    
    				<group
    					id="On2it_GroupMailMergeWriteInsertFields" 
    					label="Write and Insert Fields" 
    					insertBeforeMso="GroupMailMergeWriteInsertFields" >
    					<toggleButton 
    						idMso="MailMergeHighlightMergeFields" 
    						size="large" />
    					<button 
    						idMso="MailMergeAddressBlockInsert" 
    						size="large" />
    					<button 
    						idMso="MailMergeGreetingLineInsert" 
    						size="large" />
    					
    					<splitButton
    						id="On2it_MailMergeMergeFieldInsert" 
    						size="large" >
    						<button
    							idMso="MailMergeMergeFieldInsert" 
    							screentip="Insert Merge Fields - into both the Body and Subject of E-mail                        ." 
    							supertip="Insert Merge Fields, such as:&#13;    &#60;&#60;First Name&#62;&#62;&#13;    &#60;&#60;Company Name&#62;&#62;&#13;    or any other Field from your Recipient List.  &#13;&#13;You can't insert Fields directly into the E-mail Header, as this button gets 'greyed out' as soon as the Mouse Cursor enters the Header.  So you can either:&#13;     - type them in yourself, as shown, complete with the &#60;&#60;...&#62;&#62; at each end,&#13;     - or copy the Subject from the body of the document &#13;       and paste it into the header&#13;&#13;When you click 'Merge to E-mail', Word will replace the Merge Fields in the body of the Document with the actual information from your Recipient List and On2it Software's Macros will take care of any in the Subject. " /> 
    						<menu idMso="MailMergeMergeFieldInsertMenu"
    							screentip="Insert Merge Fields - into both the Body and Subject of E-mail                        ." 
    							supertip="Insert Merge Fields, such as:&#13;    &#60;&#60;First Name&#62;&#62;&#13;    &#60;&#60;Company Name&#62;&#62;&#13;    or any other Field from your Recipient List.  &#13;&#13;You can't insert Fields directly into the E-mail Header, as this button gets 'greyed out' as soon as the Mouse Cursor enters the Header.  So you can either:&#13;     - type them in yourself, as shown, complete with the &#60;&#60;...&#62;&#62; at each end,&#13;     - or copy the Subject from the body of the document &#13;       and paste it into the header&#13;&#13;When you click 'Merge to E-mail', Word will replace the Merge Fields in the body of the Document with the actual information from your Recipient List and On2it Software's Macros will take care of any in the Subject. " />
    					</splitButton>
    
    					<menu idMso="MailMergeRules" />
    					<button idMso="MailMergeMatchFields" />
    					<button idMso="MailMergeUpdateLabels" enabled="false" />
    				</group>
    
    				<group idMso="GroupMailMergeWriteInsertFields" visible="false" />
    
    				<group id="On2it_GroupMergeToEmail" 
    					label="On2it Software - Merge to E-mail" >
    					<button 
    						id="ADDAttachmentsToMerge" 
    						label="ADD Attachments to Mail-Merge" 
    						size="large" 
    						imageMso="AttachItem"
    						getEnabled="ADDAttachmentsToMerge_getEnabled" 
    						onAction="ADDAttachmentsToMerge_onAction" 
    						screentip="ADD Attachments to Mail-Merge                                                          ."
    						supertip="You can specify multiple Attachments to be sent to:&#13;     - all Recipients, and/or &#13;     - specific Recipients only.  &#13;&#13;To send to everyone in your Recipients list, all you need to do is add the Attachments into the E-mail Header below, as usual, and click 'Merge to E-mail' - that's it!&#13;&#13;If you want to send some Attachments to specific Recipients only, you will need to specify which Attachments to send with each E-mail separately.  You can do this using the 'Mail-Merge Attachments' Form that will open when you click this Button." />
    					<button 
    						id="On2itMergeToEmail" 
    						label="Merge to E-mail" 
    						size="large" 
    						imageMso="CreateEmail"
    						getEnabled="On2itMergeToEmail_getEnabled" 
    						onAction="On2itMergeToEmail_onAction" 
    						screentip="Merge to E-mail                                                                        ."
    						supertip="This will generate your E-mails and send them to Outlook.&#13;&#13;If you have specified Attachments in the the E-mail Header below, they will be sent to everyone in your Recipients list&#13;&#13;If you used the 'ADD Attachments to Mail-Merge' Button then some Attachments will be sent to only to the Recipients you selected or 'ALL Recipients' if that's what you wanted.  " />				
    				</group>
    			</tab>
    		</tabs>
    	</ribbon>
    </customUI>
    
       

    As you can see I have hidden the original Group: "GroupMailMergeWriteInsertFields" and replaced it with "On2it_GroupMailMergeWriteInsertFields".  This was because I found I could not hide the splitButton in the original group, but I could hide the whole Group and start from scratch. 

    "

    On2it_GroupMailMergeWriteInsertFields"


    GroupMailMergeWriteInsertFields"visible="false"/>

    Tuesday, June 30, 2015 10:02 AM

Answers

  • Hi Brian

    I'm imagine the menu would be fine, although when I do mail merge I do tend to use the list...

    Thinking about it, if your UI doesn't need to be exactly like the one "out-of-the-box" you could have two idMso controls? One for the dialog and one for the list?

    Generating the list and writing the selection to the document are perfectly possible. But if you're under time constraints it does take a bit of work...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by L.HlModerator Tuesday, July 7, 2015 10:45 AM
    Friday, July 3, 2015 3:54 PM
    Moderator

All replies

  • Hi Brian

    Unfortunately, without the code to go with this Ribbon XML, it's nigh on impossible to do any testing - I keep getting macro errors. Can you trim this down to something we can reproduce?

    Also, does the non-appearance of the menu items rely on the length of the supertip, or is that a red-herring?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, June 30, 2015 4:05 PM
    Moderator
  • Hi Cindy,

    Once again, many thanks for your help.  This is the first time I've tried messing around with an Office Ribbon.  So you'll have to forgive me. 

    I'm afraid shortening the supertips did not work - a total red-herring. 

    I've uploaded all three components of my application to  
         https://www.dropbox.com/sh/rjpsjxumoh1ocdh/AAD8VhmCYNRM9c16ccnqwWHia?dl=0
    There's a Word Document, an Excel Spreadsheet and a small Access Database.  Simply download them into the same test folder and open the Word Document.  When it opens it will attach the spreadsheet as its data source and your in. 

       

    To see how the usual Word buttons usually work simply set:
    "GroupMailMergeWriteInsertFields"visible="true".

    What I'm working on now is purely cosmetic defects.  Everything is working, but I'm striving to make the UI as familiar as possible. 

    Is there any chance you can assist with https://social.msdn.microsoft.com/Forums/en-US/e32101cd-ede1-4328-b288-0cc41e646add/how-do-i-extract-the-original-pathnames-of-the-attachments-in-a-word-document-mailenvelope?forum=worddev?   I've been waiting to hear back on that for over a month now.  Once we've sorted this issue out, that's going to be my only outstanding item.  I've programmed a work-around into my Access Database, but that's no where near as elegant as using the Attachments from the MailEnvelope - as that's what folks as used to.

    Regards
    Brian

    Wednesday, July 1, 2015 2:15 AM
  • Hi Brian

    I've d/l the sample, but don't have time to look at it today.

    I'm unfortunately not able to help with the other problem.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, July 1, 2015 4:44 PM
    Moderator
  • Hi Brian

    It appears that you can't include a built-in menu as the menu for a split button. It works as soon as I take away the idMso and include a button child element.

    I think you'll need to generate the list of fields yourself, probably as a dynamic menu as a child of the menu since splitButton doesn't appear to support a dynamic menu. Or use a separate button for the list.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, July 2, 2015 2:32 PM
    Moderator
  • Hi Cindy,

    Do you think I'd get away with it if I went away from using a SplitButton and just used a Menu referencing the built-in menu?  I'll give it a go and see if it works.

    For even if I generate my own dynamic menu to list all the column headings in my attached Excel Datasource, which I have no idea how to do, then I'd still have to supply my own logic to insert the selected Merge Field into the body of the text.  I think that's an idea that's going to remain in the 'Too Hard' Basket.

    I'll let you know how I get on.  At least the top half of the SplitButton works, so I can use just that without loosing functionality.  However the menu is better, more direct, option.

    Regards
    Brian

    Friday, July 3, 2015 1:51 AM
  • Hi Brian

    I'm imagine the menu would be fine, although when I do mail merge I do tend to use the list...

    Thinking about it, if your UI doesn't need to be exactly like the one "out-of-the-box" you could have two idMso controls? One for the dialog and one for the list?

    Generating the list and writing the selection to the document are perfectly possible. But if you're under time constraints it does take a bit of work...


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by L.HlModerator Tuesday, July 7, 2015 10:45 AM
    Friday, July 3, 2015 3:54 PM
    Moderator
  • Hi Cindy,

    I tried using just the Menu part of the Split Button on its own, but could not get it to work.  So I've gone back to just using the Button part, which works just fine.

    Regards
    Brian

    Tuesday, July 7, 2015 10:51 PM