Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-13-2020, 03:33 AM
JellehFishh JellehFishh is offline Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document Windows 7 64bit Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document Office 2010
Novice
Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document
 
Join Date: Jun 2019
Posts: 5
JellehFishh is on a distinguished road
Default Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document

Hi all,



I have been using the following macro for a long time and it works great, one significant improvement is if I can get it to also change PreserveFormatOnUpdate = True, but I can't figure it out!

Any help would be greatly appreciated!!


Code:
Sub HyperlinkFormatting()
    Dim fld As Field
    Dim Resp

    ' If no documents are open then exit
    If Documents.Count = 0 Then
        Exit Sub
    End If
    
    ' Confirm the action to format all the hyperlinks in the document
    Resp = MsgBox("Are you sure you want to format all the hyperlinks in this document?", _
        vbYesNo + vbQuestion + vbDefaultButton2, "Format Hyperlinks - Confirm?")
        
    If Resp = vbNo Then
        Exit Sub
    End If
    
    ' Loop through all fields in the active document
    For Each fld In ActiveDocument.Fields
        If fld.Type = wdFieldPageRef Or _
            fld.Type = wdFieldRef And InStr(1, fld.Code, "\h", 1) <> 0 Or _
            fld.Type = wdFieldHyperlink Then
            
                fld.Locked = False
                fld.Result.Font.ColorIndex = wdBlue
                
        End If
    Next fld
End Sub
Reply With Quote
 

Tags
field, hyperlink, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document Why are style updates in VBA not reflected in the document? FlyingBlind Word VBA 5 02-16-2019 01:57 PM
Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document A mystery: how to hop about in a document, inserting updates in a single, new font? markh10178 Word 3 11-26-2015 04:07 PM
Adding PreserveFormatOnUpdate to macro that updates all hyperlinks within a document Updates tries to install Office 2010 updates which I don't use jlumbtx Office 1 03-13-2015 04:50 PM
Automating document updates with new text wordfoolish2 Word 0 01-04-2011 01:01 PM
Hyperlinks get messed when adding or deleting some slides? Learner7 PowerPoint 0 05-17-2010 04:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:16 AM.


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