How to maintain Bold font and underline in Text replacement 
Author Message
 How to maintain Bold font and underline in Text replacement

Hi There,
I am using below code to insert text into document from a
word form which has 2 command buttons "Insert"
and "cancel". However, whenever I clcik "Insert" after I
typed in bold font with underline, actual insertions are
changed as "Headings1" or"headings2" styles and positioned
in the centre without underline.
Is there anyway that I can sure the same fonts and style
that I typed are exactly showing on the document after I
click "insert"??
Many thanks
*********
Private Sub cmdInsert_Click()
  ActiveWindow.ActivePane.View.ShowAll = True
  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst
  Selection.Find.ClearFormatting

  With Selection.Find
      .Text = "Insert text after this line:"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop

      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
  End With

  If Selection.Find.Execute = True Then
    Selection.MoveRight
    Selection.Extend "$"
    Selection.Copy
  End If
  Application.Documents(2).Activate

  ActiveDocument.ActiveWindow.View.ShowAll = True
  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst

  With Application.Selection.Find
    .Text = "[example]"

    .Forward = True
    .Wrap = wdFindStop
    .Replacement.Text = ""
    .Format = False

    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
  End With

  With Selection

    While Selection.Find.Execute
      .Find.Execute replace:=wdReplaceOne
      Selection.Paste
    Wend
  End With
  ActiveDocument.ActiveWindow.View.ShowAll = False
  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst
  Me.Close wdDoNotSaveChanges
  Unload Me

End Sub



Sun, 16 Jan 2005 03:45:02 GMT  
 How to maintain Bold font and underline in Text replacement
Hi There,
After several hours of struggle, I found the fact that a
document setting was not right. I believe nothing wrong
with the macro I listed.
Thanks,
Quote:
>-----Original Message-----
>Hi There,
>I am using below code to insert text into document from a
>word form which has 2 command buttons "Insert"
>and "cancel". However, whenever I clcik "Insert" after I
>typed in bold font with underline, actual insertions are
>changed as "Headings1" or"headings2" styles and
positioned
>in the centre without underline.
>Is there anyway that I can sure the same fonts and style
>that I typed are exactly showing on the document after I
>click "insert"??
>Many thanks
>*********
>Private Sub cmdInsert_Click()
>  ActiveWindow.ActivePane.View.ShowAll = True
>  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst
>  Selection.Find.ClearFormatting

>  With Selection.Find
>      .Text = "Insert text after this line:"
>      .Replacement.Text = ""
>      .Forward = True
>      .Wrap = wdFindStop

>      .Format = False
>      .MatchCase = False
>      .MatchWholeWord = False
>      .MatchWildcards = False
>      .MatchSoundsLike = False
>      .MatchAllWordForms = False
>  End With

>  If Selection.Find.Execute = True Then
>    Selection.MoveRight
>    Selection.Extend "$"
>    Selection.Copy
>  End If
>  Application.Documents(2).Activate

>  ActiveDocument.ActiveWindow.View.ShowAll = True
>  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst

>  With Application.Selection.Find
>    .Text = "[example]"

>    .Forward = True
>    .Wrap = wdFindStop
>    .Replacement.Text = ""
>    .Format = False

>    .MatchCase = False
>    .MatchWholeWord = False
>    .MatchWildcards = False
>    .MatchSoundsLike = False
>    .MatchAllWordForms = False
>  End With

>  With Selection

>    While Selection.Find.Execute
>      .Find.Execute replace:=wdReplaceOne
>      Selection.Paste
>    Wend
>  End With
>  ActiveDocument.ActiveWindow.View.ShowAll = False
>  Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst
>  Me.Close wdDoNotSaveChanges
>  Unload Me

>End Sub
>.



Mon, 17 Jan 2005 02:51:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Bolding and Underlining Text

2. bold, italic and underline buttons.

3. Help: replace bold, italic and underline

4. Applying a style turns off bold, italic, or underlining

5. Bold, italics, underline, strikeout at the same time

6. bold, underline and italic for a rtf-control

7. RFT to HTML Bold,Italic,Underline,Bullet

8. manipulating bold and underlined in the rich_text?

9. Toolbar icons (Bold, Underline, Italic, ...)

10. RichTextBox Bolding, Italicizing, and Underlining

11. Bold/Italics and underline in an Editor box!!

12. bold, italic and underline buttons.

 

 
Powered by phpBB® Forum Software