Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word: Decipher Legacy Code - WordBasic object 1

Status
Not open for further replies.

llamaman

Programmer
Jan 9, 2002
49
US
Two questions. I have the following piece of code that is attached to a menu item.

Code:
Public Sub MAIN()
WordBasic.WW7_EditAutoText Name:="Birth Certificate", Context:=1, InsertAs:=0, Insert:=1
WordBasic.InsertPara
End Sub

This code inserts a paragraph into the document at the point of the cursor. Where is the text stored and how do I update it?

When I put breaks in the code and try to run the menu item, it doesn't break at the point I specify.

Next question: I cannot find the code that inserts the items in the menu. There is no Auto routines in the document. How do I find the code that inserts the menu? It is a template file, so are the menus included with the template?

Thanks,
Llamaman
 
I'm not sure this answers your first question but the AutoTextEntries are saved in the templates, either the Normal template or some other template upon which the document is based. If you just want to change the AutoText entry manual you will find it in Tools, AutoCorrect..., AutoText tab.

I'm not familar with the WordBasic equivalents but this example will hopefully give you an idea of how to manipulate the autotext entry in VBA.

Sub autotext_example()
' this example assumes a document is open which is based on the Normal template

' create autotext named 'my example' from the text in the current paragraph
' which will be saved in the Normal template
Selection.TypeText "text to be written when autotext is inserted"
NormalTemplate.AutoTextEntries.Add Name:="my example", _
Range:=Selection.Paragraphs(1).Range

' change the value of the autotext entry 'my example'
' looks for the autotext in the Normal template
NormalTemplate.AutoTextEntries.Item("my example").Value = "new stuff"

' insert the text of the autotext entry 'my example' in a new paragraph
' inserted after the current selection;
' looks for the autotext in the Normal template
Selection.TypeParagraph
NormalTemplate.AutoTextEntries("my example").Insert Where:=Selection.Range

' change the value of the autotext entry 'my example'
' looks for the autotext in the template on which the current document is based
ActiveDocument.AttachedTemplate.AutoTextEntries("my example").Value = "more stuff"

' insert the text of the autotext entry 'my example' in a new paragraph
' inserted after the current selection;
' looks for the autotext in the template on which the current document is based
Selection.TypeParagraph
ActiveDocument.AttachedTemplate.AutoTextEntries("my example").Insert Where:=Selection.Range
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top