Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 01-09-2015, 05:02 AM
ptmuldoon ptmuldoon is offline Referencing FieldCodes in VBA Windows 7 64bit Referencing FieldCodes in VBA Office 2013
Advanced Beginner
Referencing FieldCodes in VBA
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using FieldCodes, AutoText, BuildingBlocks ptmuldoon Word 5 01-02-2015 01:33 PM
Auto referencing SharkAttack Word 5 02-17-2013 07:09 PM
Referencing darksupernova Word 4 11-08-2012 03:37 AM
Multiple referencing SPRITEtoo Word 3 01-29-2012 07:39 PM
Cross referencing maltesedog Word 0 02-13-2009 07:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:13 PM.


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