Check for Links

T

takethemoney

Hello All, I am currently working on template for a document. The
authors of these documents are to be told to insert financial values in
the text by linking using Paste Special to an excel spreadsheet. In
order to check that they have done this and not simply typed in the
figure I would like a macro to scan through (searching for £ signs)
and check that the text to the right is a field (i.e. £{Link
EXCEL......}) instead of a number (£865,000). I am coming unstuck
becuase I don't know how to search for a field. Any suggestions will be
most gratefully received.

Richard

P.S. For 1,000,000 extra bonus points - In the same documents the
authors are being to told to keep a table of references to other
documents and use bookmarks and cross-referencing to refer back to
this table when using the reference in the text (in case the titles
changes etc.). These authors are lazy, lazy people and it would be
great if I could do something like give them a button on the taskbar
which gives them a drop down list of the bookmarks currently created so
they can pick one and it'll drop in to the text. (Likewise Figures and
Tables). That would be such a boon.
 
G

Greg Maxey

Crude, but something like this might get you started. It assumes that
there are no spaces between your currency symbol and the field code.

Sub ScratchMacro()
Dim oRng As Word.Range
Dim bCurView As Boolean
Set oRng = ActiveDocument.Range
bCurView = ActiveWindow.View.ShowFieldCodes
If bCurView = False Then ActiveDocument.Fields.ToggleShowCodes
With oRng.Find
.Text = "$"
While .Execute
oRng.MoveEnd wdCharacter, 6
If InStr(oRng.Text, "LINK") = 0 Then
MsgBox "Foul"
oRng.MoveEnd wdCharacter, -6
oRng.HighlightColorIndex = wdBrightGreen
If bCurView = False Then ActiveDocument.Fields.ToggleShowCodes
Exit Sub
End If
oRng.Collapse wdCollapseEnd
Wend
End With
If bCurView = False Then ActiveDocument.Fields.ToggleShowCodes
End Sub

What is one bonus point worth in English pounds?
 
T

takethemoney

Hi Greg, thanks so much that works a treat. I modified it to look for
'£' and '£ ' so that got round the space after issue. I'm afraid
bonus points can only be traded for hugs at the moment. I'm working on
modifying a macro called MyBookMarkAddin which I found on the web.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top