Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2016, 03:10 AM
rdross51 rdross51 is offline VBA Code to Access Building Block Template in Word 2013 Startup folder Windows 7 32bit VBA Code to Access Building Block Template in Word 2013 Startup folder Office 2010 32bit
Advanced Beginner
VBA Code to Access Building Block Template in Word 2013 Startup folder
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Default VBA Code to Access Building Block Template in Word 2013 Startup folder

I have the following macro to insert a building block into a document:
Sub OpsTech()


'
' OpsTech Macro
'
'
Application.Templates( _
"C:\Users\robert.ross\AppData\Roaming\Microsoft\Wo rd\STARTUP\BBTechTemplate.dotx" _
).BuildingBlockEntries("Ops Tech").Insert Where:=Selection.Range, _
RichText:=True
End Sub

I need to modify this so it is not user specific. Multiple writers will have this template installed in their Startup folder.
Reply With Quote
  #2  
Old 05-31-2016, 03:50 AM
gmayor's Avatar
gmayor gmayor is offline VBA Code to Access Building Block Template in Word 2013 Startup folder Windows 10 VBA Code to Access Building Block Template in Word 2013 Startup folder Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,299
gmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to allgmayor is a name known to all
Default

That is fairly straightforward e.g.
Code:
Dim strPath As String
    'strPath = Environ("AppData") & "\Microsoft\Word\STARTUP\BBTechTemplate.dotx"
    'or to account for users who may have moved the startup folder
    strPath = Application.Options.DefaultFilePath(wdStartupPath) & "\BBTechTemplate.dotx"

    Application.Templates(strPath).BuildingBlockEntries("Ops Tech").Insert _
            Where:=Selection.Range, _
            RichText:=True
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 06-01-2016, 07:05 PM
rdross51 rdross51 is offline VBA Code to Access Building Block Template in Word 2013 Startup folder Windows 7 32bit VBA Code to Access Building Block Template in Word 2013 Startup folder Office 2010 32bit
Advanced Beginner
VBA Code to Access Building Block Template in Word 2013 Startup folder
 
Join Date: Feb 2015
Location: Abu Dhabi
Posts: 45
rdross51 is on a distinguished road
Smile Seems to work

Thank you! It works on my machine. Now I need to test it on another persons machine to make sure it works for them as well.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Word - Building Block (AutoText) - Array - Replace Text with Specific Building Blocks jc491 Word VBA 7 01-03-2016 10:34 PM
A yes or no OptionButton in Userform inserts a building block HighSierra Word VBA 3 06-14-2015 11:19 PM
VBA Code to Access Building Block Template in Word 2013 Startup folder How to share building block macros? rdross51 Word VBA 7 03-12-2015 08:59 AM
VBA Code to Access Building Block Template in Word 2013 Startup folder Custom Building Block File Locations ptmuldoon Word 5 01-03-2015 08:45 AM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:33 PM.


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