Autotext

J

Jen

Hi all

Randomizer code below selects Autoetxt entries randomly and inserts at end
of active document.

My question is - is it possible to alter the below code to select Multiple
Autotext Entries by entering the Autotext entry's
name(s), for example:

Question2
Question3
Question10

selecting from Attached Template.

Can those autotext entries load into an array?

Then have the code insert the selected Autoext entries in order of selection
into active document, preferably at current cursor position not at end of
document?

Thanks for ANY help.
 
J

Jen

Hi Tony
Thanking everyone for their patience.

I have 150 autotext entries which could be used to create the content of
each document. Authors will dictate the autotext entries required, for
example:

Question1
Question3
Question10
Question2

I need to provide an input box for the user to type the question numbers: 1,
3, 10, 2.

And then insert the corresponding autoext from attached template.

I have only done boilerplate with two listboxes where users can add and
remove selected clauses from liist box and then the documents are inserted
into active document. I have now converted these documents to autotext.

Or can I use the two listbox method - on left are selections and on right
are the selections to be added to document? I will try that. I am not sure
if this is easiest way to insert autotext entries.

And am still unaware of how to insert multiple autoext entries with a loop.

Hope this is a little clearer. Not too experienced with VBA.

Thank you
 
T

Tony Jollans

This seems to be a better worded version of your earlier question.

You seem to be asking if code can be written to rack up a load of autotexts
and enter them all at once. Of course it can but what purpose would it
serve? It would be quicker, easier, and more accurate to use the standard
Word interface.

I haven't looked at your code but I'm sure most of it is related to the
randomising rather than the autotexts themselves and I'm sure it could be
easily altered but can you give a bit more detail as to what you really
want?
 
T

Tony Jollans

And what is the problem with using Insert > AutoText > AutoText?

You could write a macro which prompted for autotext IDs but it would have to
validate them all in case of typos. To run it you would have to start it up
somehow (maybe off a custom toolbar) and type in the names one by one.
Alternatively you could start up the built in list (maybe off the built in
toolbar) and just select the ones you wanted. I really don't see why you
need a macro but something like this should get you started ...

Dim ATNames() As String
ReDim ATNames(0)

Do
ATNames(UBound(ATNames)) = InputBox("Next")
If ATNames(UBound(ATNames)) = "" Then
Exit Do
Else
ReDim Preserve ATNames(UBound(ATNames) + 1)
End If
Loop

On Error Resume Next
For ndx = LBound(ATNames) To UBound(ATNames)
ActiveDocument.AttachedTemplate.AutoTextEntries(ATNames(ndx)).Insert
Where:=Selection.Range
Next

Note that this simply ignores errors which might not be what you want.
 
F

Fred

Tony,

Autotext is used. I've also used it off the dropdown - found it loses
connection to template if template is renamed or moved during network
changes (updates and so on - IT ). Users get slightly put off with the
dropdown when it doesn't work because it cannot locate the Autotext entry,
but it was a good intro to get them using autotext.

Thank you for helping me out with this.

Like the email address (just noticed it).
 
T

Tony Jollans

Hi Fred,

Now I'm confused. If you rename or move the template, it won't be
available - unless you take specific action - regardless of how you want to
use it. Neither Word nor any macro you write is psychic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top