Ok so Here is an example of my UserForm code as was originally...
'Apply introduction as to what is included
Dim oCCA As ContentControl
Dim oCCB As ContentControl
Set oCCA = ActiveDocument.SelectContentControlsByTitle("ccINTROACTION1").Item(1)
Set oCCB = ActiveDocument.SelectContentControlsByTitle("ccINTROACTION2").Item(1)
Select Case True
'Paper Version
Case chbTR And chbR185 And Not chbAccounts
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRONLY1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbPPRTRR185").Insert Where:=oCCB.Range, RichText:=True
Case chbTR And chbAccounts And Not chbR185
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRACCOUNTS1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbPPRTRACCOUNTS").Insert Where:=oCCB.Range, RichText:=True
Case chbTR And chbR185 And chbAccounts
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRACCOUNTS1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbPPRTRACCOUNTSR185").Insert Where:=oCCB.Range, RichText:=True
Case chbTR And Not chbR185 And Not chbAccounts
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRONLY1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbPPRTRONLY").Insert Where:=oCCB.Range, RichText:=True
'Electronic Version
Case Not chbTR And chbR185 And Not chbAccounts
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRONLY1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbTRR185").Insert Where:=oCCB.Range, RichText:=True
Case Not chbTR And chbAccounts And Not chbR185
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRACCOUNTS1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbTRACCOUNTS2").Insert Where:=oCCB.Range, RichText:=True
Case Not chbTR And chbR185 And chbAccounts
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRACCOUNTS1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbTRACCOUNTSR185").Insert Where:=oCCB.Range, RichText:=True
Case Not chbTR And Not chbR185 And Not chbAccounts
Application.Templates.LoadBuildingBlocks
Set oTmp = Templates("C:\users\%username%\%appdata%\Roaming\Microsoft\Templates\Building Blocks.dotm")
oTmp.BuildingBlockEntries("bbTRONLY1").Insert Where:=oCCA.Range, RichText:=True
oTmp.BuildingBlockEntries("bbTRONLY2").Insert Where:=oCCB.Range, RichText:=True
End Select
I have tried all of the following, none of which have worked:
1. I have tried having the Building Blocks file in the StartUp folder (with the file enabled as an Add-In in the Options) obviously I changed the file path to pull from the StartUp folder instead of Templates.
2. I have tried Application.Templates.LoadBuildingBlocks.
3. I have tried
Dim m_oTmp as Template
If m_oTmp Is Nothing Then
For Each m_oTmp In Templates
If UCase(m_oTmp.Name) = "BUILDINGBLOCKS.DOTM" Then Exit For
Next m_oTmp
End If
With this coded to happen on the opening of a new document
And changed my code to
Case chbTR And chbR185 And Not chbAccounts
m_oTmp.BuildingBlockEntries("bbTRONLY1").Insert Where:=oCCA.Range, RichText:=True
m_oTmp.BuildingBlockEntries("bbPPRTRR185").Insert Where:=oCCB.Range, RichText:=True
4. I realised that my UserForm initialises on Document_New and figured that it was maybe opening before the Building Blocks had loaded so I changed it so that the UserForm was loaded manually (I have a UI Ribbon button) after the file opened.
5. I know that the Building Blocks are never loaded until you perform an action which loads them (such as using the insert building blocks function) or you tell them to load; I tried opening my file, inserting a building block (from the organizer) and then running the UserForm.
I'm assuming that, if my building blocks file is visible in the project pane then the file is loaded and should be able to be used (even though, when the actual file is not open, it will say unable to view) - is that correct? Even when the file is there in the project pane it still won't call my building blocks; I get runtime error 5941.
Please can someone tell me what I am missing?