Visual Basic "Error! AutoText Entry not defined" error

Posted on 2009-02-17
Last Modified: 2012-05-06
I have the following code:
.Range.Fields.Add(.Range, Microsoft.Office.Interop.Word.WdFieldType.wdFieldEmpty, "AUTOTEXT  ""Page X of Y"" ", True)

It worked correctly using Word 2002 SP3. However, when creating a Word document to Word 2007, "Error! AutoText Entry not defined" appears instead of "Page 1 of 8", for example.
Question by:msukow
    LVL 2

    Accepted Solution

    If all you want to do is add a Page X of Y in the lower left page footer, here is the code to do it.  Let me know if you require more.
        ActiveDocument.AttachedTemplate.BuildingBlockEntries("Bold Numbers 1"). _
            Insert Where:=Selection.Range, RichText:=True

    Open in new window


    Author Comment

    Thanks - it will take me about a week to get to this issue - priorities have changed so this is now on the back burner.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now