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
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