View Single Post
 
Old 02-12-2016, 08:08 PM
ptmuldoon ptmuldoon is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default

In continuing to learn, I believe I have learned the underlying cause is that VBA will truncate a string down to 255 characters.

Greg, I found an old post of yours here helping with a similar issue and the solution appears to insert the buildingblock into a temp file and then set a string variable to that selection. That old post is here:

http://www.vbaexpress.com/forum/arch...p/t-44367.html

I think I got it working with this, and just need to change the hardcoded building block name to a variable.

Code:
Sub BuildingBlockMsgBox()
Dim oTmp As Template
Dim sPath As String
Dim oScratchPad As Word.Document
Dim oRng As Word.Range

sPath = Environ("APPDATA") & "\Microsoft\Word\STARTUP\ReportMacros.dotm"
Set oTmp = Templates(sPath)

'oTmp.BuildingBlockEntries("Foreign AR").Insert Selection.Range
Set oScratchPad = Documents.Add(, , , False)
Set oRng = oTmp.BuildingBlockEntries("Foreign AR").Insert(Where:=oScratchPad.Selection.Range, RichText:=True)
MsgBox oRng
oScratchPad.Close wdDoNotSaveChanges
Set oScratchPad = Nothing

End Sub
Reply With Quote