• Autotext in 2010

    • This topic has 1 reply, 2 voices, and was last updated 12 years ago.
    Author
    Topic
    #489102

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

    33890-Autotext

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

    Application.Templates(“D:UsersPublicTemplatesStartupianznorm.dotm”). _
    BuildingBlockEntries(“Voluntary”).Insert Where:=Selection.Range, RichText _
    :=True

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

    Viewing 0 reply threads
    Author
    Replies
    • #1390764

      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
    Viewing 0 reply threads
    Reply To: Autotext in 2010

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: