For a mailmerge outputting its results to a document, neither of the first two assumptions is valid for any Word version and third isn't valid for Word 2007 & later. The underlying assumption seems to have been that Word can't generate mailmerge hyperlinks with: (a) different targets (b) different targets from their display text and/or (c) a different display text for each hyperlink. I would very much appreciate if you have time to look at my problem.įWIW, the previous discussion in this thread has been predicated on a mailmerge outputting hyperlink string as tagged text. Could the problem be that I have hyperlinks already in the document in terms of embedded pictures.
I have tried with another text pattern one ".text = "\(*)\" and that work but I run later into other problem in the code so I guess it must have the correct text pattern. When I run you script I get an error on the line ".Execute Replace:=wdReplaceAll" saying "Run Time Error '5560': "The FIND What text contains a Pattern Match expression which is not valid". " in the document that I would like to replace as hyperlinks (and in Italic preferably). However I am running word2010 and I have document (xxx.doc) with embedded pictures/drawing and links like " If you use any of these characters elsewhere in the document, some different (unused) characters will be needed.įinally I found a script that is doing exactly what I am looking for. 'Convert HREF codes to ' pairs are created for the field code, along with some temporary '« »' pairs for the 'Text To Display'. Replace everything in the field after 'HYPERLINK' with your mergefield.ĭim RngFld As Range, RngTmp As Range, oFld As Field, StrTmp As String, HLink As HyperlinkĪ = True Select the inserted hyperlink and press Shift-F9 to expose its field codeģ. Disregarding mergefield issues for the moment, insert a hyperlink into the document in the normal way, choosing whatever 'Click Here' text you want in the 'Text to display' box.Ģ.
Here's how to insert a HYPERLINK field with a 'Click Here' prompt into a mailmerge:ġ. There is a catch, however unless you create the HYPERLINK field with a 'Click Here' kind of display text, all the merged fields will display the first link’s address as the HYPERLINK field’s display text. You can overcome that by embedding the MERGEFIELD inside a HYPERLINK field. No macros required.Īs you've already discovered, one of the limitations of mailmerging hyperlink addresses is that they’re ordinarily rendered as plain text in the output document. I'm not expecting a fully coded solution (although that would be nice)! I'm sure I will learn a lot from this.įor your purposes, you can dispense with the tags and use Word's HYPERLINK field instead. The most complex macro I have programmed prior to this was to change table background colours.Īny guidance or pointers would be much appreciated.
I do not know how to do this on my own, or where to start. I imagine that the macro would take the text from between the > and, and apply a hyperlink field code to it, using the address. I would like to process the entire document to detect tags and make the change in each case. "Savings increase with the size of the network however, one study demonstrated energy savings between 30 and 60% over conventional computers."Īnd I want to turn the identified hyperlink and enclosed text (in this case "one study") into a clickable hyperlink. Basically, after the merge I will get a paragraph much like this: I am using tags simply because it's logical to me, but any unique identifier would do.
One cannot use concatenate to create an embedded hyperlink within an excel cell, so I thought I could include the hyperlinks using identifying tags, and then use a macro to process the mail-merged document to convert the tagged links into embedded links. The final Word document needs to have embedded hyperlinks, however, which presents an interesting challenge. I am using mail merge to import large text strings from an Excel document into Word.