Solved

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

Posted on 2011-03-03
3
419 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
ID: 35026462
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
ID: 35027029
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
ID: 35027190
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

930 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

11 Experts available now in Live!

Get 1:1 Help Now