![]() |
#1
|
|||
|
|||
![]()
Greetings to all,
I have documents that are in cyan color and it needs to be changed into magenta. Is there any way that I can achieve the desired result with the least effort? I have tried some macros from different websites to find and replace colors but failed to get the job done. I want to change the values of cyan to magenta for example 10% cyan to 10% magenta 100% cyan to 100% magenta and so on. I have attached a sample doc. Plz have a look and suggest the solution or best possible alternatives. Thanks in advance |
#2
|
|||
|
|||
![]()
The colors in your sample document do not match the values in your message; that is, the cyans in the document are not precisely 10% and 100%.
Do you mean to say that the precise cyan values in your document---whatever they may be---need to be changed to precisely 10% and 100% magenta? |
#3
|
||||
|
||||
![]()
Word doesn't work with CMYK colours so Cyan is not simply interchangeable with Magenta.
Word's colours are RGB-based so each 'cyan' colour is going to be held in Word as a combination of RGB and hence need specific matching pairs to convert 100% cyan to its rgb equivalent to use in the find and then replace it with the target rgb value. The solid cyan in your doc has RGB values of 0,174,239. The paler cyan is 225,244,253.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#4
|
|||
|
|||
![]()
Thank you Andrew and Peterson for the replies. Yeah! word doesn't work with CMYK. So, I changed 100% cyan value to RGB which corresponds to 0,174,239, and I have done the same for the 10% cyan value i.e. RGB 255,244,253. I should have used Indesign instead but I prefer working with the msword as it is more convenient and comfortable to work for me. Now, what I want to do is find those two values in the document and change RGB 0,174,239 to RGB 236,0,140 and RBG 255,244,253 to RGB 253,233,241. But they are used in various places such as for shading, borders, text boxes.
Code:
Sub Colorsquiz() Dim i As Long Dim Rng As Range Dim Para As Paragraph Set Rng = ActiveDocument.Range Const col1 As Long = RGB(0, 174, 239) Const col2 As Long = RGB(255, 244, 253) For i = 1 To Rng.Paragraphs.Count Set Para = Rng.Paragraphs(i) Para.Range.Select Select Case Para.Range.ParagraphFormat.Shading.BackgroundPatternColor Case col1 Para.Range.ParagraphFormat.Shading.BackgroundPatternColor = RGB(236, 0, 140) Case col2 Para.Range.ParagraphFormat.Shading.BackgroundPatternColor = RGB(253, 233, 241) End Select ' For Font Select Case Para.Range.Font.Color Case "(0,174,239)" Para.Range.Font.Color = RGB(236, 0, 140) End Select Next i End Sub |
#5
|
||||
|
||||
![]()
Hi to all.
With these modifications you will go a step ahead: Code:
Option Explicit Sub Colorsquiz() Dim i As Long Dim Rng As Range Dim Para As Paragraph Set Rng = ActiveDocument.Range For i = 1 To Rng.Paragraphs.Count Set Para = Rng.Paragraphs(i) Para.Range.Select Select Case Para.Range.ParagraphFormat.Shading.BackgroundPatternColor Case RGB(0, 174, 239) Para.Range.ParagraphFormat.Shading.BackgroundPatternColor = RGB(236, 0, 140) Case RGB(255, 244, 253) Para.Range.ParagraphFormat.Shading.BackgroundPatternColor = RGB(253, 233, 241) End Select 'For Font If Para.Range.Font.Color = RGB(0, 174, 239) Then Para.Range.Font.Color = RGB(236, 0, 140) Next i End Sub |
#6
|
|||
|
|||
![]()
Thank you, rollis.
|
#7
|
||||
|
||||
![]()
I tried a different approach of saving the doc as docx and then doing a search and replace in the xml files of document.xml and styles.xml.
In the XML the cyan colours were 00AEFF and E1F4FD. I changed these to 990099 and FFBDFF respectively This approach replaced everything except two elements - perhaps because they weren't exactly the same colour.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#8
|
|||
|
|||
![]()
Thank you Andrew for the reply. I found it quite confusing because i don't know much about xml files. Can you please guide me stepwise on how can I achieve the result you achieved? It would be of great help.
|
#9
|
||||
|
||||
![]()
OK, first steps are:
1. Install 7zip and Notepad++ which you can find online. 2. Open the .doc file in Word and do a SaveAs to change its format to .docx. Doc file format is very old and won't work with this method. 3. Make sure Notepad++ is set as your default application to edit .xml files. Do this by creating a text file on your machine and changing its file extension to .xml. If double clicking it opens it in Notepad++ then you are good to go. If not, right click on the file and choose Open with... to select Notepad++. Make sure you check the box that says "Always use this app to open..." I'll post the rest of the instructions later.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#10
|
|||
|
|||
![]()
All set boss!!
![]() |
#11
|
||||
|
||||
![]()
Part II
First the disclaimer - When editing a Word document with this method, you should always do it on a copy of the file. It is possible that you might make a change to the file structure which stops Word from being able to open the contents. If this is the case you can always revert to the original version. 1. In Windows Explorer, right click on the docx version of the file and choose 7zip>Open Archive. This will open a window revealing that the docx file is actually a zipped file containing folders and files. 2. Navigate inside the folder called word. Click on document.xml and then Ctrl-click on styles.xml to select them both and then Right-click on one of them and choose Open This should open both files in Notepad++. Have a look at the contents of the document.xml file and you will notice the occasional tag w:color which shows that the colors in the file are in Hex format 3. Under the Search menu, choose Replace... In the find what box type the hex code of the color you want to find (00AEFF) and in the replace with box put in the code you want to change it to (990099). Click the button that says Replace All in all opened documents 4. Do the same for the paler cyan color codes 5. Click the Save All button on the toolbar (4th one from left) and then click the Close All button (6th one from left). Then close Notepad++ 6. As you return to 7zip, you should be prompted to update the archive - choose OK and then close 7zip. Now you should be able to double click the docx file to open it in Word and have a look at the result. If you notice any remaining colours this method didn't replace, make a note of its hex value and repeat the process. In the case of the document you posted earlier in this thread, there is a cyan background on the text "Concept Review" with a different hex code. You can find out what its hex code is by noting that the shading comes from the style Bb1 which you can modify and going to Format > Border... > Shading > Select the fill > More Colors... Then make note of the hex code which says it is #44C8F5 This is your clue that your earlier search and replace should have also included this code (without the # symbol)
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#12
|
|||
|
|||
![]()
Thank you, Andrew. It did a great Job.
|
![]() |
|