Hello to all,
I hope every one is having a great January and a great Friday too.
I have come back to ask for some help.
I am at crossroads with this problem so I thought I would ask - otherwise I will be stuck like post man Pat, slowly but surely updating the wrong colors.
I will say that I don't know if its possible to solve my problem. I have been looking but I have not found anything to help me.
The disastrous Problem:
I have lots of documents that have lots of colors - like a Kaleidoscope I would say.
Edit Paragraphs With Background Color Below After Edited - New Updated Paragraph Background Color - Will be Navy Blue RGB (0,0,255) Purple* RGB (128,0,128) Aqua RGB (0,176,240) purple 1 RGB(155,48,255) Blue RGB (100,100,250) purple 2 RGB (145,44,238)
When the paragraphs have been edited and finished - they will need a new paragraph background color applied to it as per a specific color system.
I know how to do them one by one with a macro, my secret, otherwise yes I have to manually change the color with the word RGB palette - which does not always go as planned.
However the problem is I am a very visual person and oops - I have been misplacing all the colors and messing up the documents.Dim oPara As Paragraph For Each oPara In ActiveDocument.Paragraphs If oPara.Range.Shading.BackgroundPatternColor = RGB RGB (100,100,250) Then oPara.Range.Shading.BackgroundPatternColor = RGB (128,0,128)
I once applied the wrong color to 30 documents - then I couldn't find the RGB color that I originally replaced as some one deleted the VBA module, and then another color got replaced - so it turned into a case of the mysterious missing text and colors.
Now that's more work for me to fix, which took hours and hours.
I thought maybe I could have my table and that way I wont misplace the colors Or maybe I could store the colors in the table - would that work?
image.jpg
I am very sad as I tried to code for the past 5 days for hours - but nothing, I don't know what else to do?
so I must hope for some help from the very expert and kind people who know the VBA better than me by a million percent.
Sub UpdateParagraphColors() Dim myDoc As Document Dim myTable As Table Dim ParagraphColor As Range Dim FindColor As Range Dim ReplacementColor As Range Dim i As Long ' For the table Dim myFilename As String ' Open this file that has my table of colors and use it to find and replace myFilename = "C:\Users\Saphire\Desktop\UpdateParagraphColors.docx" Set myDoc = ActiveDocument Set myTable = UpdateRanges.Tables(1) For i = 1 To myTable.Rows.Count Set ParagraphColor = myDoc.Range Set FindColor = myTable.Cell(i, 1).Range Set ReplacementColor = myTable.Cell(i, 2).Range With ParagraphColor.Find .Findcolor = myTable.Cell(i, 1) .Replacement.backgroundcolor = myTable.Cell(i, 2).Replacement.color .Execute Replace:=wdReplaceAll End With Next i ' Color to find End Sub
I referenced this thread http://stackoverflow.com/questions/3...replace-tables and also many others - that had something to do with a table, as you can imagine it can be very confusing
Is it possible for me to store my colors in a table - or the RGB values and then update in one go?
That would stop me from messing up and applying all the wrong colors to the wrong paragraphs. Also manually finding the colors again is a very tedious process.
I really am hoping for a miracle solution - there is like 73 different colors to find and 73 replacement colors - and some more in the future - you can imagine how stressful that is.
If any person would be so kind to help me I would be so very very grateful and happy.
Thank you so much for your time in looking at this disastrous problem.
Saphire
Also thank you very much for the other VBA modules - I am happy to report they are working so wonderfully, and I use them everyday!