View Single Post
 
Old 04-17-2018, 05:47 AM
Kalü Kalü is offline Windows 10 Office 2010 32bit
Advanced Beginner
 
Join Date: Apr 2018
Posts: 43
Kalü is on a distinguished road
Default

Dear Paul,

Thank you very much!

It seems to work perfectly for now!

I have modified the macros so that the first macro is also copying all text and the second macro is pasting plain text. For that I recorded a macro and copied the expressions (red marked in the code below). Did I right, or is there room for any improvements? Or is there any reason to not integrate the copy&paste functions in my macros?
(Background for this adjustment is that I would like my colleagues to use the macros and they are beginners. And with that adjustment they just have to click on the macro and thats it.)

I have one more question to this adjustment: Is there the possiblity that the second macro is pasting the styles from the old document? I come to this conclusion because when I copy text and then in the new document press Ctrl. + V and chose in the pasting options that appear at the end of the text "keep text only" it sometimes keeps the styles from the old document. This is not happening when i dont press Ctrl. + V but simply rightclick and choose "keep text only".
And I have no idea what way of pasting the macro is going.

Sorry for my English! I really try to give my best and I hope you can understand what I mean

Code:
Sub aaaabTEEESTFettKursivQuelldok()
Application.ScreenUpdating = False
With ActiveDocument
  .AutoHyphenation = False
  With .Range
    .ListFormat.ConvertNumbersToText
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Format = True
      .Forward = True
      .MatchWildcards = True
      .Wrap = wdFindContinue
      .Font.Underline = True
      .Text = ""
      .Replacement.Text = "<u>^&</u>"
      .Execute Replace:=wdReplaceAll
      .ClearFormatting
      .Highlight = True
      .Replacement.Text = "<h>^&</h>"
      .Execute Replace:=wdReplaceAll
      .ClearFormatting
      .Font.Bold = True
      .Replacement.Text = "<b>^&</b>"
      .Execute Replace:=wdReplaceAll
      .ClearFormatting
      .Font.Italic = True
      .Replacement.Text = "<i>^&</i>"
      .Execute Replace:=wdReplaceAll
    End With
    .Style = wdStyleNormal
    .Font.Reset
    .HighlightColorIndex = wdNoHighlight
  End With
End With
Application.ScreenUpdating = True
   Selection.WholeStory
   Selection.Copy
End Sub
Code:
Sub aaaabFettKursivZieldok()
   Selection.PasteAndFormat (wdFormatPlainText)
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Format = True
  .Forward = True
  .MatchWildcards = True
  .Wrap = wdFindContinue
  .Replacement.Text = "\1"
  .Text = "\<[Uu]\>(*)\</[Uu]\>"
  .Replacement.Font.Underline = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Hh]\>(*)\</[Hh]\>"
  .Replacement.Highlight = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Bb]\>(*)\</[Bb]\>"
  .Replacement.Font.Bold = True
  .Execute Replace:=wdReplaceAll
  .Replacement.ClearFormatting
  .Text = "\<[Ii]\>(*)\</[Ii]\>"
  .Replacement.Font.Italic = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Reply With Quote