macro to copy clipboard to autocorrect entry, Word 2003

A

Alan Stancliff

I type out medical reports on a lot of different patients, some of whom have
odd spellings for their names. I have been putting the name for each report
into an autocorrect entry. For example, if the patient's name is
"Throckmorton," I might assign that to "uu." Then instead of typing
"Throckmorton" and maybe forgetting the spelling, I just type "uu." I do this
for each report, always using the same autocorrect shortcut "uu."

What I would like to do is to be able to highlight or select the name when
it first appears and then run a macro which automatically assign it to "uu."
I have experimented with the macro recorder by highlighting the name, hitting
<ctrl><C>, and then opening up the autocorrect dialog box and substituting
the old patient name with the new one, but Word seems to put in the literal.
There has to be some way of getting Word to paste the clipboard contents into
autocorrect, perhaps via some kind of variable assignment.

Regards,

Alan
 
J

Jay Freedman

On Sat, 19 Jan 2008 01:48:00 -0800, Alan Stancliff <Alan
I type out medical reports on a lot of different patients, some of whom have
odd spellings for their names. I have been putting the name for each report
into an autocorrect entry. For example, if the patient's name is
"Throckmorton," I might assign that to "uu." Then instead of typing
"Throckmorton" and maybe forgetting the spelling, I just type "uu." I do this
for each report, always using the same autocorrect shortcut "uu."

What I would like to do is to be able to highlight or select the name when
it first appears and then run a macro which automatically assign it to "uu."
I have experimented with the macro recorder by highlighting the name, hitting
<ctrl><C>, and then opening up the autocorrect dialog box and substituting
the old patient name with the new one, but Word seems to put in the literal.
There has to be some way of getting Word to paste the clipboard contents into
autocorrect, perhaps via some kind of variable assignment.

Regards,

Alan

Hi Alan,

The mistake is in trying to get the clipboard involved. Just create the
AutoCorrect entry directly from the selection:

Sub uuAutoCorrectFromSelection()
AutoCorrect.Entries.Add Name:="uu", Value:=Selection.Text
End Sub
 
A

Alan Stancliff

Sub uuAutoCorrectFromSelection()
AutoCorrect.Entries.Add Name:="uu", Value:=Selection.Text
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.

Thank you Jay. That's exactly what I needed and it worked!

Regards,

Alan Stancliff
www.alanstancliff.com
 
A

Alan Stancliff

I have been having trouble posting a question here, so I hope I've done this
correctly.

I've written part of a macro that pastes between two markers. The first
marker is //// and the second marker is \\\\. The macro then massages some of
the data between those two markers. It ends up looking like this:
////
bunch of data here
More data here
Even more data here
\\\\

What I want to do now is <ctrl><home> to the top of the document, search for
the //// marker, then continue to search for the \\\\ marker, so that all of
the stuff between the markers, as well as the markers themselves, are
selected.

However, I do not know how to do that. Can anyone give me some ideas on how
to accomplish this?

Regards,

Alan
 
H

Helmut Weber

Hi Alan,

Sub Test555()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "////*\\\\\\\\"
.MatchWildcards = True
If .Execute Then
rDcm.Select
End If
End With
End Sub

see: http://www.gmayor.com/replace_using_wildcards.htm

The 8 backslahes are required because in a wildcard search
a backslash is a special character and has to be doubled
in order to find it.

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 
A

Alan Stancliff

Thanks Helmut,

I would have replied here sooner, but I have been having trouble being able
to respond to posts or create new posts. I am now on my work computer instead
of my home computer, and this seems to be working better.

What I wanted to say is thank you so much for the explanation and the link.
I found them both very informative.

Regards,

Alan
 

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