|
|
Thread Tools | Display Modes |
#16
|
||||
|
||||
After running the code, check the file with your translators in Trados.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#17
|
|||
|
|||
Thank you so much!
I'll do that and I'll let you know. |
#18
|
|||
|
|||
Sorry for so many messages, Andrew.
Maybe I'm getting ahead of myself but I just did a quick test of the Macro and noticed that the gray text continues to be editable. Is that how it is supposed to be? Thank you. |
#19
|
||||
|
||||
No its not meant to work that way. But as I said before, the grey text can be defined in a myriad of ways. If you look at the code I provided, it assumes the grey is coloured using a particular colour specification - but not all greys are the same. the code I provided worked on the New file you uploaded. If you test on that file (after removing the content controls you put in there) you would see the correct result. The code is not clever enough to find every possible grey. If your other documents were consistent in exactly which grey then we could specify the exact colour to find.
A more robust solution would be to apply a particular character style to the tags and then the macro could search for that character style. It might also be possible to search for the open and close tags <> which appear to define the start and finish of a tag but if those angle brackets appear somewhere else then that code would fail.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#20
|
|||
|
|||
Hi, Andrew.
Thanks again for your help and advice. Extremely valuable and much appreciated. On the good side: It looks like in all of the files the programming text is always written in Gray (50%) On the bad one: I tried running the Macro at work but get an error message: Run-time error ‘5224’: This is not a valid section The debugging window identifies this line of code: aRng.ContentControls.Add (wdContentControlGroup) My VBA knowledge is rudimentary at best and cannot see what is creating this issue. I'll do some searching on that. (Yesterday I got the same error message and, on the fly and in my personal computer (Office 2016), I tried changing “wdColorGray50” to “wdColorGray”. The Macro ran then but I didn't get any effect from it —as expected, I suppose.) Best regards. |
#21
|
||||
|
||||
The code can be refined if you provide real sample documents which can be tested. The macro can deal with variations but without seeing what the variations are, we don't know what can be expected.
The grouping will fail under some conditions such as the presence of already grouped content or content controls. If you add a aRng.Select line in front of the problem line you will see the current range that is failing so you can examine it to work out why that particular instance failed. Another option to do troubleshooting would be to firstly apply a character style to all the 'grey' text with a macro and then examine the file to see if all the right things were found. Then the second macro could simply search for that style and group any elements.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#22
|
|||
|
|||
Hi, Andrew.
I tried a number of things to get the Macro to run but to no avail. I always got the error message 5224: “This command is not available”, directing me to the line of code: “aRng.ContentControls.Add (wdContentControlGroup)” As you indicated, I’m enclosing some (a couple) of the Word files I’m dealing with. As I mentioned, the Gray text to be locked consistently appears to be identified as 50% in all of the files. I suppose that’d help for coding –but that’s how it has been handled up to now, isn’t it? Best regards. |
#23
|
||||
|
||||
The code stumbled over something odd in those docs. I adjusted the code and this appears to work on both those samples. I added applying a character style which will make life a lot easier in the future.
Code:
Sub GroupTags() Dim aRng As Range, aCC As ContentControl ActiveDocument.Styles("Intense Emphasis").Font.Color = wdColorGray50 'Clear all CCs For Each aCC In ActiveDocument.ContentControls aCC.Delete Next aCC Set aRng = ActiveDocument.Range(0, 0) With aRng.Find .ClearFormatting .Font.Color = wdColorGray50 .Replacement.ClearFormatting .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Do While .Execute aRng.Select 'not necessary unless troubleshooting If aRng.ContentControls.Count = 0 Then aRng.Style = "Intense Emphasis" aRng.ContentControls.Add (wdContentControlGroup) End If aRng.Collapse Direction:=wdCollapseEnd Loop End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#24
|
|||
|
|||
Andrew,
I’m hugely grateful for all of your help. Truly. (Plus I’m now strongly motivated to also truly learn VBA). One of the translators was available today and he tells me that the Macro worked just fine for those files –most importantly, he also tells me, the tags for locked text that exist in the Translation Memory Units coincide with the tags resulting from your Macro. This is crucial, otherwise the Memory becomes unusable for many, if not most, of the files. However, he tried the Macro in some other files and tells me that in several of them an Error message was still produced. I took a look to two of those files and noticed that the “Group” symbol in the Developer tab always appears dimmed. I suspect that’s the issue. (The Error message pinpoints to “aRng.ContentControls.Add (wdContentControlGroup)” –“The command is not available”.) I’m searching now on my side to see if I can circumvent that issue. Thanks again and best regards. |
#25
|
|||
|
|||
Sorry, I forgot to include one of those problematic files.
Here it is. Thank you |
#26
|
|||
|
|||
Well, it looks like I’m determined to show off how truly “novice” is my stage.
Perhaps my excuse is that I wasn’t careful enough. It appears like I was trying to apply your Macro on a “Compatibility mode" file. My apologies, Andrew, for distracting you and probably make you waste your time with my previous posting. I’ll keep you posted with any more intelligent updates I may have. Best regards, |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Save as .docx without content controls (just the text that was written in them) | vitesse | Word VBA | 6 | 08-12-2022 02:01 AM |
How do I lock an editable text box header and stop it moving with the rest of the main body text? | thegaffa | Word | 6 | 09-28-2018 09:21 AM |
Most efficient way to store numerous charts? | RAB | PowerPoint | 0 | 07-13-2015 07:17 AM |
Lock Text In a Document | la_gillespie25 | Word | 4 | 05-15-2013 07:09 AM |
Animation: text appears as if written by pen | ionas.iona | PowerPoint | 0 | 03-31-2011 05:23 PM |