Solved

Can you mail merge in Word and bring the font colour from the data set through ?

Posted on 2011-03-03
3
416 Views
Last Modified: 2012-05-11
Hi,

I am actually trying to do this in Publisher but I'm sure if it is possible in Word, it will work in Publisher too.

I have a set of data in Excel. One of the columns contains text that is formatted to different colours depending on the data e.g. if the data is 'A' then the font used is green. 'B' would be orange, etc.

Is it possible to mail merge this data with a Word document and bring the font colour from Excel through into Word so that when the actual data is displayed, it is displayed in the same colour in Word as it is in Excel?

Many thanks
0
Comment
Question by:theabbeyschool
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
Comment Utility
No. The recordset that Word is using does not contain any formatting information. You would have to automate the Excel application, open the workbook and copy the data.
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
If you couls arrange an extra column os the worksheet to have text that depends on the colour of the cell, then you could use IF fields to test the text and then display the field in the appropriate colour.

Here Field a  has the data that you wish to colour and Field b has the differentiating text. I have used the words "Red, "Green" and "Black"

There may be a way of using Excel formulae to fill the colour-indicating column. Rory would know. I am sure that it is possible in VBA

a          b
Tom     Green
Dick     Black
Harry   Red  

Here is a picture of the IF and the MERGEFIELDs in the Word document. (Use Alt + F9 to toggle the field display in the Word document)
Clip0002.jpg
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
Comment Utility
Here is a simple way to fill the column with colour names in VBA. Note  that in-between shades are not catered for.


Option Explicit

Sub GetColourName()
    Dim r As Integer
    With ActiveSheet
        For r = 2 To 4
            Select Case .Cells(r, 1).Font.Color
            Case 255
                .Cells(r, 2).Value = "Red"
            Case 0
                .Cells(r, 2).Value = "Black"
            Case 65280
                .Cells(r, 2).Value = "Green"
        Next r
    End With
End Sub

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now