FW: Can a macro operate within individual fields of a Reference?

Mar 20, 2013 at 7:14 PM

I see that macros can do things like convert all in-text citations to static text and remove all uncited sources from a document.

I am interested to know whether macros can work within particular fields of a Reference.

The example I would like to see is a macro that could delete all the comments field entries in a completed Reference List.

When references are being compiled the comments field is a convenient place to record queries against particular sources.

When all the queries are resolved, it can take time to edit all the sources with comments and delete them one by one.

Can we do this in one go with a macro?

Coordinator
Mar 20, 2013 at 10:05 PM
According to the documentation of the Word Object Model it is not possible to set fields of sources. However when I experimented with it back in 2007 when the feature was first introduced, I noticed that you could change properties of a source as long as the properties were originally defined. You could use this 'bug' to your advantage to remove the comments with a macro like this:
Sub Test()
    Dim s As Source
    
    For Each s In ActiveDocument.Bibliography.Sources
        If InStr(s.XML, "<b:Comments>") > 0 Then
            s.Field("Comments") = ""
        End If
    Next
End Sub
Mar 22, 2013 at 6:25 PM

Thanks Yves, the macro works perfectly!

I appreciate your assistance here, and also deeply appreciate the work you have done in making BibWord available.