Linking an autotext entry to the author of a document

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a template for use by several different people. The signature
for each user has been scanned and saved as autotext. How do I tell Word to
automatically insert the signature of the author?

So basically what I want is - when a user opens a document based on this
template the correct signature is automatically inserted in the correct place.

Can anyone help?

Dawn
 
Dawn,

Rough (very rough). You can use the Application.UserName (method, procedure
or whatever it is called)

Provided that you have an AutoText entry that matches the user name, you
could use something like:

Sub ScratchMacro()
Dim oRng As Range
Dim pUserName As String
pUserName = Application.UserName
Set oRng = Selection.Range 'in your case this will probably be a bookmark
range
oRng.InsertAfter
(ActiveDocument.AttachedTemplate.AutoTextEntries(pUserName))
End Sub
 
WOOOOOWWWW!

I know nothing about macros! Could you give that to me in simple terms?

Thanks

Dawn
 
Dawn,

First do you want the name to change for every user that "opens" the
document or for the name to be inserted when a user "creates" the
document for the first time?

I am going to assume the latter as it makes more sense.

You will need an AutoNew macro in your Template Project. See:
http://www.gmayor.com/installing_macro.htm
You could use this code:

Sub ScratchMacro()
Dim oRng As Range
Dim pUserName As String
pUserName = Application.UserName
Set oRng = ActiveDocument.Bookmarks("SigBlock").Range
ActiveDocument.AttachedTemplate.AutoTextEntries(pUserName).Insert
Where:=oRng
End Sub

You will need to have a bookmark in the template named SigBlock.
You will need to have an AutoText entry defined for each user that you
expect to create a document from this template that matches "exactly"
the UserName. For example, my UserName is Gregory K. Maxey and I have
and AutoText entry named Gregory K. Maxey

The code code be enhanced with a bit of error handling in case a new
user came along before you had a chance to update the macro, but we can
save that for lesson two.

Actually I suppose that some wizard may come alone and suggest that you
could somehow scan your server and automatically create the autotext
entries for the registered UserNames, but that is graduate level work
and way, way over my head.
 
Hi Greg

Thanks for your reply.

It didn't work, but I don't think I did it correctly either.

Here's what I did:

I created a macro called AutoNew and copied and pasted the macro listing
that you providing.

Strangly, after I did this the toggle objects were not working so I had to
delete the template and re-install. It works now, but obviously something
went wrong.

Dawn
 
If you pasted the entire macro including the lines

then you've got two macro names and two macro routine end points.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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

Back
Top