Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2023, 04:15 AM
parag parag is offline VBA code for loading autotext using userform and commandbutton Windows 10 VBA code for loading autotext using userform and commandbutton Office 2021
Novice
VBA code for loading autotext using userform and commandbutton
 
Join Date: Dec 2023
Posts: 1
parag is on a distinguished road
Default VBA code for loading autotext using userform and commandbutton


I would be preparing a 'abc template' . The autotext entries would be stored in quick parts>gallery:autotext>category: general>save in:abc template. The template would then be double clicked to open a word document and document will be created by using autotext entries. I want a VBA code prepared such that when I click a button on the quick access toolbar, a userform/ listbox (named 'select_test_method') with a command button ((named 'Enter') opens up with the list of autotext libraries. When I select any autotext entry, the corresponding text gets loaded on the word document. word document.

This template will be shared with others via email.
Reply With Quote
  #2  
Old 12-16-2023, 12:43 PM
Italophile Italophile is offline VBA code for loading autotext using userform and commandbutton Windows 11 VBA code for loading autotext using userform and commandbutton Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

The Quick Access Toolbar cannot be shared, so you'll need to add the button to the ribbon by adding some Ribbon UI xml to the template. You'll find some info about doing this on Greg Maxey's website: Customize the Office Ribbon (It doesn't take rocket science)

However, as there are built-in galleries to display the Quick Parts I wouldn't bother trying to re-invent the wheel by writing code to display the entries and add them to the document. Add your texts to the Custom Autotext gallery and then add that control to the ribbon. This has the advantage that entries in the Custom AutoText gallery aren't visible in the standard gallery on the ribbon.

To add the gallery to the ribbon you can use xml like this:
Code:
<customUI 
	xmlns="http://schemas.microsoft.com/office/2009/07/customui">
	<ribbon >
		<tabs >
			<tab id="tabABCTemplate" insertAfterMso="TabHome" label="Your Text Here">        
				<group id="grpABCTemplate" label="Your Text Here" centerVertically="true">
                    <gallery idMso="CustomAutoTextGallery" label="Your Text Here" size="large" />
				</group >
			</tab >
		</tabs >
	</ribbon >
</customUI >
This will result in a new tab being added to the ribbon containing the Custom AutoText gallery.
Attached Images
File Type: png Screenshot 2023-12-17 112539.png (6.3 KB, 17 views)

Last edited by Italophile; 12-17-2023 at 04:27 AM.
Reply With Quote
  #3  
Old 12-22-2023, 09:29 AM
Charles Kenyon Charles Kenyon is offline VBA code for loading autotext using userform and commandbutton Windows 11 VBA code for loading autotext using userform and commandbutton Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

The Quick Access Toolbar modifications CAN be shared and can be stored in a document or global template.
Modifying the Quick Access Toolbar (QAT) in Microsoft Word

For code to insert Building Blocks, see:
Other ways to insert Building Blocks include:
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform selectbox to insert autotext aee74 Word VBA 8 02-10-2019 03:39 AM
VBA code for loading autotext using userform and commandbutton Recording code to create Autotext entries emblackett Word VBA 2 09-25-2017 02:00 AM
VBA code for loading autotext using userform and commandbutton Creating a (shared!) file with CommandButton placing AutoText into the document thmsrox Word VBA 5 07-07-2016 05:04 AM
UserForm of Autotext Entries ptmuldoon Word VBA 11 02-13-2016 09:36 AM
VBA Code in a UserForm module to delete a Command Button which opens the userform Simoninparis Word VBA 2 09-21-2014 03:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft