In point of fact, if the "Typing replaces selection" option is turned
on, the field is deleted automatically, because clicking the
macrobutton to activate it also selects it. Since the OP said his
fields were {MacroButton InsertPicture}, the inserted picture will
replace the field, if that option is set. (But if the InsertPicture
command is being intercepted by a macro of the same name, it could be
doing almost anything.)
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Hi Jay,
Interesting, yes, but from a user's perspective, it would probably be even
more efficient to code the macro triggered by the macrobutton field to
delete the calling field as part of the process.
Cheers
--
macropod
[MVP - Microsoft Word]
Jay Freedman said:
It would be interesting to compare these two for speed in a large
document with a few hundred fields.
I'd like to see a contest for the operation in Word that has the most
possible ways of being programmed.
Or this:
Sub KillMacroButtonFields()
Dim oFld As Field
If ActiveDocument.Fields.Count > 0 Then
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldMacroButton Then oFld.Delete
Next oFld
End If
End Sub
Cheers
--
macropod
[MVP - Microsoft Word]
Use something like this:
Dim oRg As Range
Set oRg = ActiveDocument.Range
oRg.TextRetrievalMode.IncludeFieldCodes = True
With oRg.Find
.ClearFormatting
.Text = "^d macrobutton"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
The .TextRetrievalMode.IncludeFieldCodes lets the search look inside
the field codes even when they're toggled off. The ^d represents the
opening field brace; when that's selected, the entire field is
selected, so replacing with nothing deletes the field.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Wed, 6 Dec 2006 18:11:01 -0800, Billy B
I have a table in a Word2000 document. In the table, I have multiple
{macrobutton insertpicture} fields. After inserting the picture, the
placeholder and text appear after the picture, taking up space and
displaying
the default text. How can I search the document and delete all instances
of
the macrobutton placeholders? I plan on running the procedure in a print
procedure code module.
Thank you very much.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.