F
Frederik Romanov
3 Part message
1 - Attn Jay Freedman
2 - Attn Peter Jamieson
3 - Solution !!!
Before I start, a question that arose. How can one assign /alter
/delete keyboard shortcuts for existing macros. I am forced to record
a new macro with the shortcut I want, paste the code from the existing
macro into this, delete the existing macro and rename the new macro -
there must be an easier way than this?
Fred.
------------------------------
Better F*** than D***
These replies reference
From: (e-mail address removed) (Frederik Romanov)
Newsgroups: microsoft.public.word.formatting.longdocs,microsoft.public.word.docmanagement,comp.os.ms-windows.apps.word-proc,microsoft.public.word.newusers,microsoft.public.word.conversions
Subject: How can one convert occurrences of a string into a field ?
1 - Attn Jay Freedman
---------------------------------------------------------------------
Thanks for the reply. I have tried the macro you suggested, after
tailoring it to perform another substitution (this version is below) :
Functional Checks -> FIELD{CHECKTYPE}
I created the field then entered and ran the macro, however it seems
to enter an infinite loop and I have to kill the WORD process in the
end without seeing if it has made any substitutions.
The first time I ran it, I stepped through all the lines of code, as
they all executed fine I hit F5 to continue. From this infinite loop
I could fairly quickly start the program manager to kill the word
process.
Then I tried it again by just running directly from the macros
pulldown list. Launching it this way I had to attempt several times
(over five minutes) to get a program manager app to launch so that I
could kill the process.
Is there something funny in the original macro, or has one of my
modifications turned it bad?
Final question - if I step through a VBA macro running in Excel, I can
see the effects taking place real time in the Excel window - this is
not the case with this macro in Word, is there a reason?
Fred
Sub MakeCheckField()
Dim curRange As Range
Set curRange = ActiveDocument.Range
With curRange.Find
.ClearFormatting
.Text = "Functional Checks"
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWholeWord = True
.MatchWildcards = False
Do While .Execute
ActiveDocument.Fields.Add _
Range:=curRange, _
Type:=wdFieldDocProperty, Text:="CHECKTYPE", _
preserveformatting:=True
curRange.Collapse wdCollapseEnd
Loop
End With
End Sub
2 - Attn Peter Jamieson
------------------------------------------------------------
Thanks too, I tried a few variants of your idea, however neither of
them allowed me to substitute normal text with a field code :
Sub ATP2Field()
'
' ATP2Field Macro
' Macro recorded 03-06-05 by Fred
'
' Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
' "DOCPROPERTY ""test-ATP"" ", PreserveFormatting:=True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "functional ATP"
.Replacement.Text = "DOCPROPERTY ""test-ATP"" "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Sub ATP2Field_man()
'
' ATP2Field-man Macro
' Macro recorded 03-06-05 by Fred
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "functional ATP"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"DOCPROPERTY ""test-ATP"" ", PreserveFormatting:=True
End Sub
3 - Solution !!! ------------------------------------------------------------
But then after experimenting I found the following solution.
To find the next occurrence of the target text "LRU"
Ctrl ;
To replace this with the field <LRU>
Ctrl '
(This field should be defined in the normal way prior to starting).
Works like a beaut.
Notice that these shortcuts are purposefully close together to allow
head-up operation.
Normal.Dot
---------------------
Sub Text_Mark()
'
' Shortcut : ^;
' Text_Mark: Mark the next occurrence of "LRU"
' Macro recorded 03-06-09 by Fred
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "LRU"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Sub Text_Field()
'
' Shortcut : ^'
' Text_Field: Replace marked text with the field DOCPROPERTY "LRU"
' Macro recorded 03-06-09 by Fred
'
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"DOCPROPERTY ""LRU"" ", PreserveFormatting:=True
End Sub
1 - Attn Jay Freedman
2 - Attn Peter Jamieson
3 - Solution !!!
Before I start, a question that arose. How can one assign /alter
/delete keyboard shortcuts for existing macros. I am forced to record
a new macro with the shortcut I want, paste the code from the existing
macro into this, delete the existing macro and rename the new macro -
there must be an easier way than this?
Fred.
------------------------------
Better F*** than D***
These replies reference
From: (e-mail address removed) (Frederik Romanov)
Newsgroups: microsoft.public.word.formatting.longdocs,microsoft.public.word.docmanagement,comp.os.ms-windows.apps.word-proc,microsoft.public.word.newusers,microsoft.public.word.conversions
Subject: How can one convert occurrences of a string into a field ?
1 - Attn Jay Freedman
---------------------------------------------------------------------
Thanks for the reply. I have tried the macro you suggested, after
tailoring it to perform another substitution (this version is below) :
Functional Checks -> FIELD{CHECKTYPE}
I created the field then entered and ran the macro, however it seems
to enter an infinite loop and I have to kill the WORD process in the
end without seeing if it has made any substitutions.
The first time I ran it, I stepped through all the lines of code, as
they all executed fine I hit F5 to continue. From this infinite loop
I could fairly quickly start the program manager to kill the word
process.
Then I tried it again by just running directly from the macros
pulldown list. Launching it this way I had to attempt several times
(over five minutes) to get a program manager app to launch so that I
could kill the process.
Is there something funny in the original macro, or has one of my
modifications turned it bad?
Final question - if I step through a VBA macro running in Excel, I can
see the effects taking place real time in the Excel window - this is
not the case with this macro in Word, is there a reason?
Fred
Sub MakeCheckField()
Dim curRange As Range
Set curRange = ActiveDocument.Range
With curRange.Find
.ClearFormatting
.Text = "Functional Checks"
.Forward = True
.Format = False
.Wrap = wdFindStop
.MatchWholeWord = True
.MatchWildcards = False
Do While .Execute
ActiveDocument.Fields.Add _
Range:=curRange, _
Type:=wdFieldDocProperty, Text:="CHECKTYPE", _
preserveformatting:=True
curRange.Collapse wdCollapseEnd
Loop
End With
End Sub
2 - Attn Peter Jamieson
------------------------------------------------------------
Thanks too, I tried a few variants of your idea, however neither of
them allowed me to substitute normal text with a field code :
Sub ATP2Field()
'
' ATP2Field Macro
' Macro recorded 03-06-05 by Fred
'
' Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
' "DOCPROPERTY ""test-ATP"" ", PreserveFormatting:=True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "functional ATP"
.Replacement.Text = "DOCPROPERTY ""test-ATP"" "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Sub ATP2Field_man()
'
' ATP2Field-man Macro
' Macro recorded 03-06-05 by Fred
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "functional ATP"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"DOCPROPERTY ""test-ATP"" ", PreserveFormatting:=True
End Sub
3 - Solution !!! ------------------------------------------------------------
But then after experimenting I found the following solution.
To find the next occurrence of the target text "LRU"
Ctrl ;
To replace this with the field <LRU>
Ctrl '
(This field should be defined in the normal way prior to starting).
Works like a beaut.
Notice that these shortcuts are purposefully close together to allow
head-up operation.
Normal.Dot
---------------------
Sub Text_Mark()
'
' Shortcut : ^;
' Text_Mark: Mark the next occurrence of "LRU"
' Macro recorded 03-06-09 by Fred
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "LRU"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
Sub Text_Field()
'
' Shortcut : ^'
' Text_Field: Replace marked text with the field DOCPROPERTY "LRU"
' Macro recorded 03-06-09 by Fred
'
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _
"DOCPROPERTY ""LRU"" ", PreserveFormatting:=True
End Sub