View Single Post
  #14   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Wildcard to Find and Replace with fields?

The following macro should then work

Dim oField As Field
Dim oRng As Range
For Each oField In ActiveDocument.Fields
If InStr(1, oField.Code, "ADDIN EN.CITE") Then
oField.Select
Selection.Collapse wdCollapseStart
Set oRng = Selection.Range
oRng.MoveStart wdCharacter, -1
If oRng.Text = " " Then
oRng.Delete
End If
End If
Next oField

http://www.gmayor.com/installing_macro.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"David Newmarch" wrote in message
news

Forgot to add that the space I wish to remove is any space that comes
immediately before the first opening curly bracket (i.e. before the
insertion
point of the citation). Sometimes there is no space before the insertion
point, in which case there's nothing I need to do.

"Graham Mayor" wrote:

Word itself does not use fields for endnotes.The fields presumably are
inserted via your EndNote software, however quickly checking at Google
there
are several EndNote packages, hence Doug's request to learn exactly what
your endnote software inserts that you wish to find. It is simple enough
to
locate fields using vba, provided you know what the field construction
is.
What exactly appears between the curly brackets {}?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org

..


"David Newmarch" wrote in
message
...
Thanks for picking this up.

EndNote bibliographical software, through the EndNote add-in for Word,
inserts in-text bibliographical citations in a Word document as fields.

I'm not concerned at this stage with modifying any fields, Switching to
a
different bibliographical style (not to be confused with Word's
formatting
styles) is a procedure that EndNote takes care without any difficulty.
My
problem is just with finding the fields so that I can delete the
now-extraneous space (in the ordinary Word text, not the field) that in
most
instances exists immediately before the point where the field has been
inserted. In other words I want to bring these fields up against the
preceding text - where previously they were inserted with a space
between
them and the preceding text.

But Word doesn't let me find ANY fields using wildcards. There are also
other fields in the document, like hyperlinks and a table of Contents,
and
when Use Wildcards is checked ^d doesn't find them either. (Without
Wildcards, ^d finds all of them.)

When the field codes are displayed, all of them (the citation entries
and
the hyperlinks and what have you) are enclosed in the usual curly
brackets. I
also tried just searching for spaces before curly brackets, but Field
Code
brackets don't seem to be findable with Find and replace.

Does this information help?


"Doug Robbins - Word MVP" wrote:

I am not sure what you mean by EndNote citation fields. If you use
Alt+F9
to toggle on the display of field codes in the Word document, what do
you
see in place of the fields that you want to modify?

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

"David Newmarch" wrote in
message
...
In Word 2007 I'm editing a paper which contains EndNote citation
fields,
and
in the course of switching the paper to a different bibliographic
style
I
need to find and replace any space that occurs before a citation.
Each
citation exists in the document as a field in Word.

With field codes toggled on, when I do a simple Find for ^d Word
finds
each
field with no trouble, but when I switch on "Use wildcards" and try
the
syntax
Find: ( )(^d) - and I have also tried ( )([^d])
I get an error message saying that ^d is not supported when the
Wildcards
check box is selected.

Can anyone help me with Find and replace syntax that will work for
this
task?



.