Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2020, 04:27 PM
proking proking is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Novice
Code line for adding Building Blocks to a macro in Visual Basic
 
Join Date: Jan 2020
Posts: 5
proking is on a distinguished road
Default Code line for adding Building Blocks to a macro in Visual Basic

I have done this before but forgot the line to add into Visual Basic to load Building Blocks so my macro with a building block inserted will work.

Last edited by Charles Kenyon; 01-07-2020 at 10:02 AM. Reason: Mark as solved
Reply With Quote
  #2  
Old 01-03-2020, 04:56 PM
Charles Kenyon Charles Kenyon is online now Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
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

Using VBA to Insent an AutoText Entry or other Building Block
Reply With Quote
  #3  
Old 01-03-2020, 06:06 PM
proking proking is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Novice
Code line for adding Building Blocks to a macro in Visual Basic
 
Join Date: Jan 2020
Posts: 5
proking is on a distinguished road
Default

Didn't see anything there that was of any help. It may help to say I remember it was a line that had something such as Load Building Blocks, that was to be added at the head of the macro, or the head of the part that actually was the Auto Text.
Reply With Quote
  #4  
Old 01-03-2020, 08:03 PM
Charles Kenyon Charles Kenyon is online now Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
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

Where can Building Blocks be stored?

  1. Do you know where your building block is stored?
  2. Is it in the Building Blocks.dotx file? Is it in the document template? Is it in another template that is already loaded as an Add-In? Is it in a template that you have to load before you can use the building block?
  3. What kind of building block is it?
  4. Why are you using a macro for this?
  5. What is it supposed to do when it is inserted?
Right now, you are asking for help to get home. I don't know where you live or what kind of transportation you might have. Need some more information here.
Reply With Quote
  #5  
Old 01-04-2020, 06:03 PM
proking proking is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Novice
Code line for adding Building Blocks to a macro in Visual Basic
 
Join Date: Jan 2020
Posts: 5
proking is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Where can Building Blocks be stored?

  1. Do you know where your building block is stored?
  2. Is it in the Building Blocks.dotx file? Is it in the document template? Is it in another template that is already loaded as an Add-In? Is it in a template that you have to load before you can use the building block?
  3. What kind of building block is it?
  4. Why are you using a macro for this?
  5. What is it supposed to do when it is inserted?
Right now, you are asking for help to get home. I don't know where you live or what kind of transportation you might have. Need some more information here.
building blocks is a Dotx file in User Appdata
One of teh building blocks is: Click or tap here to enter text. called for executive session. Note: "The Click or tap here" is auto text. This building block is used with time also. so the Macro is as follows:
Sub OutOfOrder()
'
' OutOfOrder Macro
'
'
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineSingle
Selection.InsertDateTime DateTimeFormat:="h:mm am/pm", InsertAsField:= _
False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineNone
Application.Templates( _
"C:\Users\cking\AppData\Roaming\Microsoft\Docu ment Building Blocks\1033\16\Building Blocks.dotx" _
).BuildingBlockEntries("OutOfOrder").Insert Where:=Selection.Range, _
RichText:=True
End Sub

Now to get that to work when I first open My Word Template, I must open Building blocks, or there is a line that can be added to the Macro that loads building blocks so it loads when I first use my macro.
I am trying to find out what teh wording is to add that to my Macro, so it will automatically load when first used.
I hope this help in the explanation.

Thank you
Reply With Quote
  #6  
Old 01-04-2020, 07:47 PM
gmaxey gmaxey is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

You need to add this line of code before you attempt to insert the building block:

Templates.LoadBuildingBlocks
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 01-05-2020, 09:42 AM
proking proking is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Novice
Code line for adding Building Blocks to a macro in Visual Basic
 
Join Date: Jan 2020
Posts: 5
proking is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
You need to add this line of code before you attempt to insert the building block:

Templates.LoadBuildingBlocks
OK that looks similar to the line I had been told before that I lost. I am having trouble finding where to add it. I tried several places, and so far noithing has worked. Am I missing something on how to add it?
Reply With Quote
  #8  
Old 01-05-2020, 12:34 PM
gmaxey gmaxey is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Any place in the macro you currently have before the line:
Code:
Application.Templates( _
        "C:\Users\cking\AppData\Roaming\Microsoft\Docu  ment Building Blocks\1033\16\Building Blocks.dotx" _
        ).BuildingBlockEntries("OutOfOrder").Insert Where:=Selection.Range, _
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #9  
Old 01-05-2020, 02:47 PM
proking proking is offline Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Novice
Code line for adding Building Blocks to a macro in Visual Basic
 
Join Date: Jan 2020
Posts: 5
proking is on a distinguished road
Smile

Quote:
Originally Posted by gmaxey View Post
Any place in the macro you currently have before the line:
Code:
Application.Templates( _
        "C:\Users\cking\AppData\Roaming\Microsoft\Docu  ment Building Blocks\1033\16\Building Blocks.dotx" _
        ).BuildingBlockEntries("OutOfOrder").Insert Where:=Selection.Range, _
THANK YOU!!!!!!!
It worked!!!! I had tried it before I responded, but I had put in Template.LoadBuildinglocks (Leaving off the s in Templates.) when I put it in correctly it worked.
Again Thank you so much.
Reply With Quote
  #10  
Old 01-07-2020, 10:05 AM
Charles Kenyon Charles Kenyon is online now Code line for adding Building Blocks to a macro in Visual Basic Windows 10 Code line for adding Building Blocks to a macro in Visual Basic Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
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

Note: This is Situation 3: Building Block stored in Building Blocks.dotx
in the link I gave you previously.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code line for adding Building Blocks to a macro in Visual Basic Macro to list building blocks yacov Word VBA 11 12-09-2019 06:13 AM
Need help with Visual Basic for Presentations to make a Macro Edward222 PowerPoint 0 05-30-2017 03:13 PM
Problem batch adding autotext using Greg Maxey's Building Blocks Add-In Genuine Gin Word VBA 5 12-16-2015 10:20 AM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM
Code line for adding Building Blocks to a macro in Visual Basic Visual basic code for Word 2003 template KateAus Word VBA 4 09-09-2012 08:40 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:01 PM.


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