+ Reply to Thread
Results 1 to 5 of 5

Find uppercase paragraph + replace string

  1. #1
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    72

    Find uppercase paragraph + replace string

    Hello,

    We get documents in from external people that we need to reformat. I'm looking at automating this and part of it is applying specific styles to specific parts of text.

    What I want to do first, is select the whole document and apply a base style. Then find only all paragraphs where all of the text is uppercase and then apply a specific style to them. Lastly, these docs have manual number lists that usually are a number followed by a period followed by a tab. For example, 1.<tab>, 10.<tab> etc.. I'd like to apply yet another style to these parts (for auto-numbering), obviously deleting the manually entered text before-hand.

    Thanks

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Find uppercase paragraph + replace string

    Try:
    Please Login or Register  to view this content.
    Naturally, you'll need to supply your own Style names.

    Note: It's not apparent whether you might have paragraphs beginning with 1.<tab>, then all upper-case text. As coded the macro will apply the UpperCaseStyle to them. If that is an issue, you could change:
    .Style = "UpperCaseStyle"
    to:
    If .Style <> "NumberedStyle" Then .Style = "UpperCaseStyle"
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    72

    Re: Find uppercase paragraph + replace string

    Thanks!

    A slight mistake on my part. The lines beginning with number.tab don't need to be all caps too, just have the number.tab characters removed, which I managed with:

    Please Login or Register  to view this content.
    I'll play with the rest of your code and see how I get on.
    Last edited by ldoodle; 11-06-2018 at 09:20 AM.

  4. #4
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    72

    Re: Find uppercase paragraph + replace string

    EDIT: Just re-read your post and see you are changing from manual line numbering to auto. I'll keep this in mind but for now I'm not sure if all of these lines even need numbering so that will be down to the user to decide (and manually set the ones that do need numbering).

  5. #5
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Find uppercase paragraph + replace string

    Quote Originally Posted by ldoodle View Post
    EDIT: Just re-read your post and see you are changing from manual line numbering to auto
    Nothing in the code I posted does that. If anything of that kind is happening, it's because of the attributes assigned to one or more of the Styles you're using.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find and replace string if value find in column
    By ghostexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-07-2016, 10:42 AM
  2. [SOLVED] Find the first two Uppercase letters in a string and return that value
    By CrazyPerson in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-13-2016, 03:40 PM
  3. Find and replace a new sentence or paragraph in word doc
    By krazyhype19 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-03-2014, 06:06 AM
  4. [SOLVED] Find a string by VBA Regular Expression and replace a part of that string
    By taps in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-25-2013, 11:08 AM
  5. Replies: 1
    Last Post: 01-19-2012, 03:07 PM
  6. Find / Replace in a string
    By Basu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-12-2006, 10:55 AM
  7. [SOLVED] Find and Replace in a DDE string!!!
    By Mark Dullingham in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2006, 08:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1