Microsoft Office Forums Searching WORD files for specific link ???

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-12-2019, 08:23 AM
ksor ksor is offline Searching WORD files for specific link ??? Windows 10 Searching WORD files for specific link ??? Office 2016
Advanced Beginner
Searching WORD files for specific link ???
 
Join Date: Feb 2018
Location: Århus V, Denmark
Posts: 31
ksor is on a distinguished road
Default Searching WORD files for specific link ???

I have a bunch of WORD-files in some subfolders.





In each file can be links inserted - maybe more, maybe no links at all.


When links are inserted it can be to the internet or to some local files.


How can I by VBA find out if a specific link are used or not in these files ?


In fact I'm looking for a function something like this:


IsThisLinkUsedIn(<link>,<top folder>)


and the function should just returning TRUE if the link IS used in ONE file in the subfolders or FALSE if the link is NOT used at all in any file in the subfolders.


I can do the treversing of the files (I think), but I'm not aware of how to search each file for a link via VBA - how can I do that ?
Reply With Quote
  #2  
Old 10-12-2019, 08:33 PM
gmayor's Avatar
gmayor gmayor is online now Searching WORD files for specific link ??? Windows 10 Searching WORD files for specific link ??? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,996
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

You can check the documents using a function similar to
Code:
Function IsThisLinkUsedIn(strLink As String, oDoc As Document) As Boolean
Dim oLink As Hyperlink
    For Each oLink In oDoc.Hyperlinks
        If oLink.Address = strLink Then
            IsThisLinkUsedIn = True
            Exit For
        End If
    Next oLink
    Set oLink = Nothing
End Function
e.g.
Code:
Sub Macro1()
MsgBox IsThisLinkUsedIn("https://www.gmayor.com/Word_pages.htm", ActiveDocument)
End Sub
Loop through the documents in a folder and check each one with the function and stop looping when you find the document that returns True. The link string must be the exact address of the link.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Tags
function, links

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching WORD files for specific link ??? Saving new word documents to specific files maxbeedie Word 1 11-15-2016 04:04 AM
Searching WORD files for specific link ??? Batch create word files with link to changing excel hannes.ledegen Mail Merge 8 04-07-2016 01:22 AM
Searching WORD files for specific link ??? Searching Multiple PowerPoint & Word Files BobbyAre PowerPoint 14 08-12-2012 06:52 AM
Searching WORD files for specific link ??? searching for text in multiple excel files roytom Excel 2 07-30-2012 01:57 PM
searching for Link in my Outlook Msg. body... JeffBPaarsa Outlook 0 03-30-2012 05:02 PM


All times are GMT -7. The time now is 11:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft