AutoText

A

Anne P.

Hi all,

I found this line regarding AutoText in the VBA help file:

Selection.CreateAutoTextEntry "handdel", "Mailing Instructions"

This line would create an AutoText entry called handdel in the Mailing
Instructions category from the selection in the current document. If I keep
changing the information in the quotes to what I want it to be, it works
fine.

I am trying to create a macro that would automate this for me, as I have a
lot of new entries I want to create in particular categories. Following is
my code:

Public Sub CreateNewAutoText()
Dim strATName As String
Dim strATCategory As String
'Get the AutoText Name
Dim Message, Title
Message = "Enter the name for the AutoText Entry" ' Set prompt.
Title = "Create AutoText Entry" ' Set title.
strATName = InputBox(Message, Title)

'Get the AutoText Category
Dim atMessage, atTitle
Message = "Enter the category for the AutoText Entry" ' Set prompt.
Title = "Create AutoText Entry" ' Set title.
strATCategory = InputBox(atMessage, atTitle)

Selection.CreateAutoTextEntry "strATName", "strATCategory"
End Sub

When I run the macro, instead of what I expect, I get a new category called
stATCategory, with a new entry named strATName.

Am I dreaming here that I can do this?

Thanks,
Anne
 
J

Jay Freedman

Hi all,

I found this line regarding AutoText in the VBA help file:

Selection.CreateAutoTextEntry "handdel", "Mailing Instructions"

This line would create an AutoText entry called handdel in the Mailing
Instructions category from the selection in the current document. If I keep
changing the information in the quotes to what I want it to be, it works
fine.

I am trying to create a macro that would automate this for me, as I have a
lot of new entries I want to create in particular categories. Following is
my code:

Public Sub CreateNewAutoText()
Dim strATName As String
Dim strATCategory As String
'Get the AutoText Name
Dim Message, Title
Message = "Enter the name for the AutoText Entry" ' Set prompt.
Title = "Create AutoText Entry" ' Set title.
strATName = InputBox(Message, Title)

'Get the AutoText Category
Dim atMessage, atTitle
Message = "Enter the category for the AutoText Entry" ' Set prompt.
Title = "Create AutoText Entry" ' Set title.
strATCategory = InputBox(atMessage, atTitle)

Selection.CreateAutoTextEntry "strATName", "strATCategory"
End Sub

When I run the macro, instead of what I expect, I get a new category called
stATCategory, with a new entry named strATName.

Am I dreaming here that I can do this?

Thanks,
Anne

Hi Anne,

No, you're not dreaming. You just need one little correction. In the
line
Selection.CreateAutoTextEntry "strATName", "strATCategory"

remove the four quote marks. You need to pass the values of the two
string variables to the function, but what you're passing now are the
literal strings "strATName" and "strATCategory".
 
A

Anne P.

Jay,

It's amazing but I had it that way to begin with (without the quotes) and
got error messages. The only thing I can think of is that the code was in
the global template originally, but this time since I am editing the global
template, I put it into Normal.

I have another question about this:

Is there anyway that I can control which template the AutoText items go
into? The AutoText items that I am currently creating, I really want to go
into a global template that will go into the startup directory. These will
be items that will be transferred to all new users. After that is done I
want to distribute this macro to the users to be able to create AutoText
entries and organize them into categories in their Normal.dot.

When it worked just now these items were put into Normal.dot. I then used
the organizer to copy them over to my global template (SKGlobal.dot).
However, I then had a category named "Privileged and Confidential" with an
AutoText of the same name underneath it. So now it seems by copying, I have
lost the Stamp category and gained a new category for each stamp that was
defined (about 25 of them).

Thanks,
Anne
 

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