Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    472
    Thanks
    43
    Thanked 0 Times in 0 Posts

    Autotext in 2010

    Hi
    I developed several templates in Word 97 that inserted autotext at specified bookmarks. Now under 2010 I get this error

    Autotext.JPG

    I have tried using Application.ActiveDocument but his does not work either. When I record a macro it shows the following:

    Application.Templates("D:\Users\Public\Templates\S tartup\ianznorm.dotm"). _
    BuildingBlockEntries("Voluntary").Insert Where:=Selection.Range, RichText _
    :=True

    Can anyone help as we have quite a few templates that use these references
    cheers

    Phil Carter

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,515
    Thanks
    3
    Thanked 143 Times in 136 Posts
    Are you sure the building block is in that template? Your code points at a different entry than the one you recorded.

    I don't know if this is the problem but with the 2007+ versions it is now possible to have lots of building blocks with the same name if their type and category aren't the same. For this reason, I am now a bit more specific about which building block I want to add to a document. The following code includes a line which demonstrates this. The rest of the code is useful for doing an audit of all the template building blocks.
    Code:
    Sub InsertAllTemplateBuildingBlocks()
      Dim i As Integer, oTemplate As Template, sName As String
      Set oTemplate = ActiveDocument.AttachedTemplate
      If oTemplate.BuildingBlockEntries.Count > 0 Then
        For i = 1 To oTemplate.BuildingBlockEntries.Count
          With oTemplate.BuildingBlockEntries.Item(i)
            sName = .Type.Name & " > " & .Category.Name & " > " & .Name
            Selection.TypeText "===================================" & vbCr & sName & vbCr
            oTemplate.BuildingBlockTypes(.Type.Index).Categories(.Category.Name).BuildingBlocks(.Name).Insert _
                  Where:=Selection.Range, RichText:=True
            Selection.TypeParagraph
          End With
        Next
      End If
    End Sub
    Last edited by Andrew Lockton; 2013-05-07 at 20:42.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •