+ Reply to Thread
Results 1 to 2 of 2

Keep Characters formatting bold, italic and underline when change style.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-24-2005
    Posts
    104

    Keep Characters formatting bold, italic and underline when change style.

    Dear friends,

    Hi,

    Please help me about these macros, that are found from http://www.vbaexpress.com/forum/show...haracter-style

    Private Const UNIQUECODE = "xyzzy" 
    Sub MarkBold_ApplyStyle_ReplaceBold() 
         
         'mark the text
        With Selection.Range.Duplicate.Find 
            .Format = True 
            .Font.Bold = True 
            .Font.italic = True
            .underline = wdsingleunderline
            .Replacement.text = UNIQUECODE & "B" & UNIQUECODE & "^&" & UNIQUECODE & "BE" & UNIQUECODE 
            .Wrap = wdFindStop 
            .Execute Replace:=wdReplaceAll 
        End With 
         
         'apply the style
        Selection.Style = "Special" 
         
         'replace the formatting, using a wildcard search
        With Selection.Range.Duplicate.Find 
            .text = UNIQUECODE & "B" & UNIQUECODE & "*" & UNIQUECODE & "BE" & UNIQUECODE 
            .Replacement.Font.Bold = True 
            .MatchWildcards = True 
            .Execute Replace:=wdReplaceAll 
        End With 
         
         'now remove the special codes
        With Selection.Range.Duplicate.Find 
            .text = UNIQUECODE & "B" & UNIQUECODE 
            .Replacement.text = "" 
            .Execute Replace:=wdReplaceAll 
             
            .text = UNIQUECODE & "BE" & UNIQUECODE 
            .Replacement.text = "" 
            .Execute Replace:=wdReplaceAll 
        End With 
         
    End Sub
    Some of the text work good and some not woked. Please help me


    Regards,

    Imran
    Last edited by internet_imran; 05-16-2016 at 01:33 AM.

  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,835

    Re: Keep Characters formatting bold, italic and underline when change style.

    Maybe you would care to explain what your code is supposed to do, including what the "Special" Style is?
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ 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] if the column K,L is in bold and italic,the move also is in bold italic
    By hktom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2015, 05:21 AM
  2. [SOLVED] Need to 'Bold' & 'Underline specific characters in a field
    By KatieKat440 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-19-2013, 03:57 PM
  3. [SOLVED] A macro that will underline, bold, and change to red color text individual words.....
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2012, 01:48 PM
  4. Bold, Underline and Italic greyed out
    By drgogo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2009, 09:30 AM
  5. Replies: 2
    Last Post: 02-28-2008, 01:45 PM
  6. Replies: 4
    Last Post: 05-25-2006, 07:35 AM
  7. [SOLVED] formatting (underline/bold/strikethrough) in comment boxes
    By adam l via OfficeKB.com in forum Excel General
    Replies: 3
    Last Post: 11-08-2005, 02:00 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