Discussion on:

11
Comments

Join the conversation!

Follow via:
RSS
Email Alert
Do your users need to perform this type of document cleanup task on a regular basis? What other macros do you provide for automating specialized chores like this one?
0 Votes
+ -
Would something like this work with Smart Tags as well? Also, is there a way to export Smart Tags to another document?
Very useful macro! Thank you!
But it doesn't work in footnotes... How it may be modifyed for this?
0 Votes
+ -
Solution
popkov@... Updated - 7th May 2007
I have written the macro that removes EndNote field codes (converts EndNote fields to text) in current Word document not only in endnotes and footnotes, but also in Shapes.
This macro identifyes EndNote fields by it's type - ADDIN.
That is the code:
------- code --------------------
Sub RemoveAddin_FieldCodes()
nResult = VBA.Interaction.MsgBox("Вы уверены, хотите удалить все коды полей типа ADDIN?", vbOKCancel, "Действие необратимо!")
If nResult = vbOK Then
Dim doc As Document
Dim fld As Field
Dim ftnt As Footnote
Dim endnt As Endnote
Dim shp As Shape
Dim shp2 As Shape
Dim shp3 As Shape
Set doc = ActiveDocument
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
For Each fld In doc.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
For Each ftnt In doc.Footnotes
For Each fld In ftnt.Range.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
Next ftnt
For Each endnt In doc.Endnotes
For Each fld In endnt.Range.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
Next endnt
For Each shp In doc.Shapes
If shp.Type = msoTextBox Then
For Each fld In shp.TextFrame.TextRange.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
End If
If shp.Type = msoGroup Then
For Each shp2 In shp.GroupItems
If shp2.Type = msoTextBox Then
For Each fld In shp2.TextFrame.TextRange.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
End If
Next shp2
End If
If shp.Type = msoCanvas Then
For Each shp2 In shp.CanvasItems
If shp2.Type = msoTextBox Then
For Each fld In shp2.TextFrame.TextRange.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
End If
If shp2.Type = msoGroup Then
For Each shp3 In shp2.GroupItems
If shp3.Type = msoTextBox Then
For Each fld In shp3.TextFrame.TextRange.Fields
' fld.Result.Select
If fld.Type = wdFieldAddin Then
fld.Unlink
End If
Next fld
End If
Next shp3
End If
Next shp2
End If
Next shp
Set fld = Nothing
Set ftnt = Nothing
Set doc = Nothing
Set shp = Nothing
Set shp2 = Nothing
Set shp3 = Nothing
End If
End Sub
-----------code----------------
0 Votes
+ -
solution
IRGconserv@... 19th Jun 2008
I can't get the "footnote" macro to run--when I hit F5 it asks ????? about the second line of the macro:

nResult = VBA.Interaction.MsgBox("Вы уверены, хотите удалить все коды полей т
You may find more detailed instructions on my macro here:
http://popkov.googlepages.com/RemovingFieldCodes.htm
Fantastic macro. I've been in a panic about how to remove 700 pages of field codes from a manuscript before sending it to a publisher. After creating the huge index, the only way I could find to remove the code was by deleting one by one. You have saved me many days of tedious work and headaches! Thanks.
hi, i have a problem removing the 'return' character (the one that looks like a backwards 'L' with a little arrow on the bottom leg). It is not recognised by the find/replace function, and I can't copy it and then paste it into the 'find' field of find/replace.
Any ideas or tips to do this?
Ta.
This is great! But I needed an additional feature for it: Only remove index entries with specific heading levels.

This is my solution:
Note Because I use a Dutch Word 2003 version, the formate names are Dutch too. You should change Kop into heading; Voorwoord into Preface etc.


Attribute VB_Name "IndexMarkeringenVerwijderen"

' IndexMarkeringenVerwijderen Macro
' Macro extended 25-1-2010 by Casey.Dronten
'


'There are a number of field code types. To get a full list of constants for the wdFieldType class, use the Object Brower. In the VBE, press [F2] or choose Object Browser from the View menu. In the Classes list, find wdFieldType to update the Members list. Or simply highlight wdFieldIndexEntry in the subprocedure and press [Shift][F2] to display the constants in the Object Browser.
'Tip

Sub IndexMarkeringenVerwijderen()
Dim doc As Document
Dim fld As Field
Set doc = ActiveDocument
For Each fld In doc.Fields
fld.Select



If (Selection.ParagraphFormat.Style Like "Kop [0-9]") Or (Selection.ParagraphFormat.Style Like "Voorwoord") Or (Selection.ParagraphFormat.Style Like "Index") Then
'MsgBox Selection.ParagraphFormat.Style
If fld.Type = wdFieldIndexEntry Then
Response = MsgBox("Wilt u deze indexmarkering verwijderen? [" & Selection.Text & "] opmaakprofiel: " & Selection.ParagraphFormat.Style, vbYesNoCancel, "Indexmarkering verwijderen")
If Response = vbYes Then
fld.Delete
End If
If Response = vbCancel Then
Exit For
End If
End If
End If

Next
Set fld = Nothing
Set doc = Nothing
End Sub




Casey
It fails and highlights the word "Dim" in this initial phrase: Sub DeleteIndexEntries() Dim doc

There are 2 spaces ahead of "Dim" and 1 after it.

Is something wrong w/ the code? I pasted it in verbatim, except for trading "wdFieldFootnoteRef" for "wdFieldIndexEntry"
It fails whether or not I keep original entry for the "wd" area.

Word 2007 Help, as is often the case, is obtuse and does not define a precise way to fix this problem. I don't know what "Dim" means.

I don't know VBE, so maybe it's just not as obvious to me as it would be to a programmer? Please help!
Thanks in advance for your help!
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.