Search for hyperlinks within folder

B

Bob

I have a macro that searches through each document in a
folder looking for hyperlinks to a user specified file,
say 'Diesel Fuel Pumping'.

Instead of searching for links to the full title, what if
I search for links to only part of the title say, 'Fuel'
or 'Diesel Fuel'.

How would I do this?
 
D

DA

How are you doing your current search?
Seems strange that if you're already searching for a
title, why can't you search for any type of string?
 
B

Bob

Hi DA

The macro loops through each hyperlink in a document (from
1 to ActiveDocument.Hyperlinks.Count) and extracts the
link path using ActiveDocument.Hyperlinks(i).Address.

The macro then searches backwards though path from Len
(.Address) until it finds a /. The hyperlinked file name
starts the first character after the / and goes until Len
(.Address).

This hyperlinked file name is then compared to the
specified name.

Do you have any suggestions or an alternative method?
 
D

Doug Robbins - Word MVP

Use Instr() on the .Range of the hyperlink.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
B

Bob

Thanks Doug

InStr work well. But the .Range gives the reference in the
document (same as .TextToDisplay) and has no relation to
the file that is hyperlinked. using Word 2000
 
D

Doug Robbins - Word MVP

Use

Dim alink As Field, linkcode As Range

For Each alink In ActiveDocument.Fields
If alink.Type = wdFieldHyperlink Then
Set linkcode = alink.Code
If InStr(linkcode, "Diesel Fuel") Then
'Some action
End If
End If
Next alink


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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