View Single Post
 
Old 01-09-2015, 05:02 AM
ptmuldoon ptmuldoon is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Sep 2014
Posts: 93
ptmuldoon is on a distinguished road
Default

Thanks jjfreedman. But I think I didn't explain it correctly.

Basically, i want to be able to place the FieldCode Link Information into the datablock.

I'm getting pounded with snow today, so hopefully I can do some more playing and learning in my 'down time' today

Code:
Sub AddCustomBuildingBlock()
    Dim objTemplate As Template
    Dim objBB As BuildingBlock
    Dim objRange As Range
    Dim FilePath As String
 
    ' Set the template to store the building block
    Set objTemplate = Templates("C:\Users\paul.muldoon\AppData\Roaming\Microsoft\Word\STARTUP\Report Building Blocks.dotm")
 
    'How Do I get his FilePath/Section of Link Field Code into the datablock instead of the text below.
    FilePath = "LINK Excel.SheetMacroEnabled.12 ""C:\\Data\\Samples\\Sample WP.xlsm"" ""Cover Charts!Charts_Cover_Main"" \p"
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=FilePath, PreserveFormatting:=False
  
    ' Collapse the range, set the range, and add the text
    Selection.Collapse
    Set objRange = Selection.Range
 
    objRange.Text = "Building blocks for the technically challenged"
  
     ' Add the building block to the template
        Set objBB = objTemplate.BuildingBlockEntries.Add( _
        Name:="Title", _
        Type:=wdTypeAutoText, _
        Category:="General", _
        Range:=objRange)
 
End Sub
Reply With Quote