Macro programming

K

KristyTaylor

Hi, I'm a medical transcriptionist and am trying to program two macros that
let me insert the patient's first name and last name with keyboard shortcuts,
calling the names from fields automatically inserted when I generate the
document. I guess my problem is that the code I wrote has two selection
objects, which apparently is not allowed, so I was wondering if there is a
way to break them up so they can operate separately.. here is the code,
thanks for any suggestions you might have:

Sub Macro1()
'
' FirstName Macro
' Macro recorded 11/26/2009 by KT
'
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCPROPERTY ""PatientFirstName""", PreserveFormatting:=True
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdTitleWord
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=" "
End Sub
------------------------------------------------------------------------------
Sub Macro2()
'
' LastName Macro
' Macro recorded 11/26/2009 by KT
'
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"DOCPROPERTY ""PatientLastName""", PreserveFormatting:=True
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdTitleWord
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=" "
End Sub
 
D

Doug Robbins - Word MVP

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

and the following pages of fellow MVP Greg Maxey's website :

http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

http://gregmaxey.mvps.org/Populate_UserForm_ListBox.htm

Greg also has an article on his website on repeating data that may be of
interest to you.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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