[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Highlight Text

Posted on 2012-04-10
8
Medium Priority
?
325 Views
Last Modified: 2012-04-10
Hello Experts,

I have an .txt file which contains .js contents and open it in word document. I would like to highlight the text which is not present between the double quotes. please find below the sample for this.

    BUTTON_SAVE         : "Save",
    BUTTON_OK           :       "OK",
    BUTTON_CANCEL       :       "Cancel",


Can you please suggest any word macro or .vbs file for this?

Thanks in Advance.
Shail
0
Comment
Question by:ShaileshShinde
  • 4
  • 3
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 37826493
It isn't clear exactly what you need to be highlighted. You can't highlight text which isn't present and anyway there are no empty quoted strings in your example.
0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 37826519
Hello Experts,

I would like to highlight the uppercase words that is [BUTTON_SAVE         :],  [BUTTON_OK           :] and leaving rest untouched...

Thanks,
Shail
0
 
LVL 1

Expert Comment

by:everlast4308
ID: 37826582
If I may offer a (crude?) solution...

Assuming colons are uniquely dividing the content you WANT from the content you DON'T WANT, you can further separate them to facilitate Column-Mode selection:

1) Open your TXT file in Notepad++.
2) Find/Replace (CTRL+H)-- find[:]  replace[:\t\t\t\t\t]
-- Note: You need to specify Search Mode: Extended at the bottom of the Find box.
-- This will separate WANT from DON'T WANT by a large amount of dead space.
3) Turn word-wrap OFF (View menu > Word Wrap (you want it unchecked).
4) Use Column-Mode selection to grab the uppercase terms; either:
-- 4.a) Hold ALT+SHIFT while highlighting with the mouse.
-- 4.b) Hold ALT+SHIFT while using the arrow keys to highlight.
5) Copy and paste to new, or copy/select-all/paste to overwrite in existing file.
6) Finally, if there is any excess tabbing within the result, simply find[\t] replace[]

There are many other ways to manipulate a text file, including scripting (as you alluded to), but this can be done pretty quickly, and in a rather simple "usery" kinda way.  I hope it helps!
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
LVL 1

Author Comment

by:ShaileshShinde
ID: 37826622
Hello Experts,

This works! However, the other engineers who is going to perform this task has requested for a MACRO or VBScript.

Thanks,
Shail
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 37826718
Try this macro:
Sub HL()
    Dim rng As Range
    Set rng = ActiveDocument.Range
    With rng.Find
        .MatchWildcards = True
        .Text = "(BUTTON_[A-Z ]{1,}):"
        Do While .Execute
            rng.HighlightColorIndex = wdYellow
            rng.Collapse wdCollapseEnd
            rng.End = ActiveDocument.Range.End
        Loop
    End With
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 37827118
Hello Expert,

can it be possible to remove the hardcoded text BUTTON from the line of code...and use regex instead.

.Text = "(BUTTON_[A-Z ]{1,}):"

The reason for this is we can use this for other file with same patterns but might have something else instead of "BUTTON".  

Thanks,
Shailesh
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 37827161
Word Wildcards act very much like Regex.

We would need to know the rules for what to find. The text "BUTTON_" is quite specific and defines precisely what is to be found.

This string: "[A-Z ]{1,}" will find any string of upper-case characters and spaces. Is the underscore always there and are the letters always upper-case? If so, you could try this:

.Text = "[A-Z]{1,}_[A-Z ]{1,}:"
0
 
LVL 1

Author Closing Comment

by:ShaileshShinde
ID: 37827202
Thanks Experts!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 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