Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 11-22-2018, 02:48 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default


After running the code, check the file with your translators in Trados.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #17  
Old 11-22-2018, 02:57 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

Thank you so much!
I'll do that and I'll let you know.
Reply With Quote
  #18  
Old 11-22-2018, 04:06 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

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.
Reply With Quote
  #19  
Old 11-22-2018, 08:18 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #20  
Old 11-23-2018, 11:11 AM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

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.
Reply With Quote
  #21  
Old 11-23-2018, 08:51 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #22  
Old 11-24-2018, 10:52 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

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.
Attached Files
File Type: docx R4_C2_HSARHE_CP_OON_ANOC.docx (18.3 KB, 9 views)
File Type: docx R4_C3_HSARHE_CP_OON_ANOC.docx (19.9 KB, 7 views)
Reply With Quote
  #23  
Old 11-25-2018, 01:14 AM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #24  
Old 11-25-2018, 01:00 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

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.
Reply With Quote
  #25  
Old 11-25-2018, 02:17 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

Sorry, I forgot to include one of those problematic files.
Here it is.
Thank you
Attached Files
File Type: docx One of the problematic files.docx (16.7 KB, 6 views)
Reply With Quote
  #26  
Old 11-25-2018, 04:52 PM
Gilvv Gilvv is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2016
Posts: 30
Gilvv is on a distinguished road
Default

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,
Reply With Quote
Reply



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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft