|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Creating a (shared!) file with CommandButton placing AutoText into the document
Hi,
I've been trying to create a document with CommandButtons that once clicked write the AutoText programmed into them. This works perfectly locally, but not externally. The main issue is that I don't want other users to have to get a copy of my "Normal.dotm" file every time since it's too much of a hassle with the amount of AutoText used. The idea was to put just one copy of my Normal.dotm on a shared drive over the network and to have the code pull out that file so users would never have to swap around files on their PCs. Something like this; Quote:
The original code does. Quote:
|
#2
|
||||
|
||||
Don't even think of sharing your normal template. It is a personal and single user file that is not intended to be shared.
Create a new template. Copy your macros and building blocks to it, save it as macro enabled then supply that template as an add-in. Include a ribbon to call your macros and make it even more useful. The code to call a building block from that template would be Code:
Application.Templates(ThisDocument.FullName).BuildingBlockEntries("Bio").Insert Where:=Selection.Range, RichText:=True Put it in the Word startup folder with Word closed - If you have not changed the preferred startup folder it can be located (in English language versions of Windows) by typing %appdata%\Microsoft\Word\Startup in the Windows Explorer Address bar and pressing Enter.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thanks for the help,
everything worked fine as you instructed, but only inside the template. Once I load the template and use it as a document, when I click one of the CommandButtons it gives me the text-output from a different CB. After that no matter which other CB I attempt to click, nothing happens. I have about 15 of these in the code behind the template. Code:
Private Sub CommandButton210_Click() Application.Templates( _ "V:\Folder\Filename.dotm" _ ).BuildingBlockEntries("AutoTextName").Insert Where:=Selection.Range, _ RichText:=True End Sub |
#4
|
||||
|
||||
The point is that with the approach I suggested (and demonstrated in the attachment) is that the template is used as an add-in. It is not intended to be used as a document. By using the add-in approach, the macros are available to all your documents.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
The main idea is that the users have a template with the macrobuttons already in place, so that they can keep re-using that same form. Once in place all that I would need to do in case of changes to the texts hidden behind the macro's is adjust those in the template that the users keep calling on. The plan is to have the users not use those macro's on their own documents, but just keep using the ones in that single document. Sorry if I didn't explain this thoroughly.
|
#6
|
||||
|
||||
In that case use the example template as a document template instead of an add-in. Create new documents from it. The macro will work just the same in those documents.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AutoText List - Protected Document | AJohn403 | Word | 3 | 04-20-2015 04:54 PM |
how to easily drop autotext into document | Kendel | Word | 2 | 02-08-2015 09:50 AM |
I'm having trouble creating a Merge using label form and placing a shape in the text | blockie | Mail Merge | 8 | 11-13-2013 11:28 PM |
Email Document via Commandbutton | aqhibjaveed | Word VBA | 1 | 03-25-2013 11:22 PM |
Creating a shared template with selections | gmsp26 | Word | 1 | 04-14-2011 05:18 PM |