Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-27-2025, 07:11 PM
macropod's Avatar
macropod macropod is offline Hyperlink inside if then else statement in word Windows 10 Hyperlink inside if then else statement in word Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Update:

If you add the following macro to your mailmerge main document, clicking on the 'Edit Individual Documents' button will intercept the merge and convert any email and hyperlink strings in the output document to working hyperlinks.

Code:
Sub MailMergeToDoc()
Application.ScreenUpdating = False
Dim bHead As Boolean, bList As Boolean, bBullet As Boolean, _
  bOther As Boolean, bQuote As Boolean, bSymbol As Boolean, _
  bOrdinal As Boolean, bFraction As Boolean, bEmphasis As Boolean, _
  bHLink As Boolean, bStyle As Boolean, bMail As Boolean, bTag As Boolean
'Store the current autoformat options
With Options
  bHead = .AutoFormatApplyHeadings
  bList = .AutoFormatApplyLists
  bBullet = .AutoFormatApplyBulletedLists
  bOther = .AutoFormatApplyOtherParas
  bQuote = .AutoFormatReplaceQuotes
  bSymbol = .AutoFormatReplaceSymbols
  bOrdinal = .AutoFormatReplaceOrdinals
  bFraction = .AutoFormatReplaceFractions
  bEmphasis = .AutoFormatReplacePlainTextEmphasis
  bHLink = .AutoFormatReplaceHyperlinks
  bStyle = .AutoFormatPreserveStyles
  bMail = .AutoFormatPlainTextWordMail
  bTag = .LabelSmartTags
End With
'Restrict autoformating to emails and hyperlinks
With Options
  .AutoFormatApplyHeadings = False
  .AutoFormatApplyLists = False
  .AutoFormatApplyBulletedLists = False
  .AutoFormatApplyOtherParas = False
  .AutoFormatReplaceQuotes = False
  .AutoFormatReplaceSymbols = False
  .AutoFormatReplaceOrdinals = False
  .AutoFormatReplaceFractions = False
  .AutoFormatReplacePlainTextEmphasis = False
  .AutoFormatReplaceHyperlinks = True
  .AutoFormatPreserveStyles = False
  .AutoFormatPlainTextWordMail = True
  .LabelSmartTags = False
End With
'Execute the Mailmerge
ActiveDocument.MailMerge.Execute
'Apply the autoformating to the output document
ActiveDocument.Range.AutoFormat
'Restore the original autoformat options
With Options
  .AutoFormatApplyHeadings = bHead
  .AutoFormatApplyLists = bList
  .AutoFormatApplyBulletedLists = bBullet
  .AutoFormatApplyOtherParas = bOther
  .AutoFormatReplaceQuotes = bQuote
  .AutoFormatReplaceSymbols = bSymbol
  .AutoFormatReplaceOrdinals = bOrdinal
  .AutoFormatReplaceFractions = bFraction
  .AutoFormatReplacePlainTextEmphasis = bEmphasis
  .AutoFormatReplaceHyperlinks = bHLink
  .AutoFormatPreserveStyles = bStyle
  .AutoFormatPlainTextWordMail = bMail
  .LabelSmartTags = bTag
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Export Embedded Docs inside Word dhen21dx Word 2 03-25-2019 01:58 AM
Converting a Select statement in Excel to an update statement shabbaranks Excel Programming 5 10-31-2018 11:47 PM
Text inside text boxes create headings inside my table of contents!!! How do I delete the created he carstj Word 3 04-11-2016 12:46 PM
How to create a MS word file that automatically logs something specific inside other WORD files? meys Word VBA 1 01-04-2015 05:22 AM
Invoking a command line from inside Word bolpom Word 1 03-16-2011 03:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:48 PM.


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