Fixed Text editor eats up space character

Dragokas

Member
Hello,

When we are copying text from MS Word document (I attached example) to text editor, some 'space' characters are disappear:

Есть две причины, по которым вы могли бы захотеть остановить процесс. Во-первых, вы можете остановить программу безопасности, котораяможет помешать фиксу.
There should be two separate words in hightlighted part.

Compare: If we'll copy the same text from MS Word to Notepad / AkelPad / N++, all characters are displayed correctly.

Also, I'd like to pay attention on this thread: https://xenforo.com/community/threads/ms-word-paste-fix.115266/

Thanks.
 

Attachments

This is non-standart editor. When we are testing it last time, it had obvious bugs and we generally disliked it for other reasons too.
So, we decided to refuse using of it. That's why it is not an option.

My bug report apply to standart edoitor only. We don't plan to replace it.
 
This is non-standart editor. When we are testing it last time, it had obvious bugs and we generally disliked it for other reasons too.
So, we decided to refuse using of it. That's why it is not an option.

My bug report apply to standart edoitor only. We don't plan to replace it.

Have you tried pasting as plain text? Just a right click away. Pasting into something like notepad basically is the same thing. While more advanced editors such as the ones in forum software attempt to preserve formatting, MS Word has a ton of garbage to deal with. Pasting only the pure text value from the clipboard usually works better if you need no special formatting.
 
Hi, rainmotorsports !
There is no probem with pasting through an transitional editor like Notepad. But your suggestion destroys all sens of preparing articles on MS Word.
When there are 10 pages of MS Word, I am able to recover formatting manually. But if there a lot -> it's almost impossible and no sens.

cclaerhout, thank you. Maybe if I was Java Developer, it could be a way.
Intead of that I found another solution that correctly works for any forum -> I wrote MS Word macros which replace several kinds of formatting into BB-codes.
So, maybe it will be useful to other people who face with this problem too. I decided to public it here.

Sequence: Run macros on your MS Word article*, copy resulting text to Notepad, copy text from Notepad to forum. Profit.
Currently macros configured on such kinds of formatting:
- replace font size (10, 12, 14, 16). By default - 12.
- replace hyperlinks
- bold
- italic
- red color
- blue color
- center alignment
- and any combinations of these

* to apply macro, you should insert it once on normal.dot. Then It will be work on any document without necessity to paste it again.
On any doc, Left ALT + F8, Create, Change, insert following code.
To apply macro on your doc -> open your doc, Left Alt + F8, choose name of macro, Run.
Code:
Option Explicit

Private Enum TEXT_PROPERTY
    TEXT_BOLD = 1
    TEXT_ITALIC
    TEXT_SIZE_10 = 10
    TEXT_SIZE_12 = 12
    TEXT_SIZE_14 = 14
    TEXT_SIZE_16 = 16
    TEXT_RED
    TEXT_BLUE
    TEXT_CENTER
End Enum

Private Type POSITION_CONTEXT
    BEG As String
    END As String
End Type

Private Type BB_TAG_CODE
    BOLD            As POSITION_CONTEXT
    ITALIC          As POSITION_CONTEXT
    TEXT_SIZE_10    As POSITION_CONTEXT
    TEXT_SIZE_12    As POSITION_CONTEXT
    TEXT_SIZE_14    As POSITION_CONTEXT
    TEXT_SIZE_16    As POSITION_CONTEXT
    COLOR_RED       As POSITION_CONTEXT
    COLOR_BLUE      As POSITION_CONTEXT
    POS_CENTER      As POSITION_CONTEXT
End Type

Private Const DEFAULT_SIZE = TEXT_SIZE_12   'размер текста по-умолчанию

Public TAG As BB_TAG_CODE

' заполнение соответствий форматирования MS Word и BB-кодам

Private Sub Mapping_Init()
    With TAG
        .BOLD.BEG = "[b]"
        .BOLD.END = "[/b]"
        .ITALIC.BEG = "[i]"
        .ITALIC.END = "[/i]"
        .TEXT_SIZE_10.BEG = "[size=3]"
        .TEXT_SIZE_10.END = "[/size]"
        .TEXT_SIZE_12.BEG = "[size=4]"
        .TEXT_SIZE_12.END = "[/size]"
        .TEXT_SIZE_14.BEG = "[size=5]"
        .TEXT_SIZE_14.END = "[/size]"
        .TEXT_SIZE_16.BEG = "[size=6]"
        .TEXT_SIZE_16.END = "[/size]"
        .COLOR_RED.BEG = "[color=red]"
        .COLOR_RED.END = "[/color]"
        .COLOR_BLUE.BEG = "[color=blue]"
        .COLOR_BLUE.END = "[/color]"
        .POS_CENTER.BEG = "[center]"
        .POS_CENTER.END = "[/center]"
    End With
End Sub


Public Sub A_Replace_Into_BBcode()
    Dim Style1
    Dim Style2
    Dim Style3
    Dim Style4
    Dim Style5
  
    Dim hh As Hyperlink
  
    For Each hh In ActiveDocument.Hyperlinks

        hh.TextToDisplay = "[url=" & hh.Address & "]" & IIf(hh.TextToDisplay = "", "X", hh.TextToDisplay) & "[/url]"
        hh.Delete
  
    Next
  
    Call Mapping_Init
  
    For Each Style1 In Array(TEXT_BOLD, 0)
  
        For Each Style2 In Array(TEXT_ITALIC, 0)
      
            For Each Style3 In Array(TEXT_SIZE_10, TEXT_SIZE_12, TEXT_SIZE_14, TEXT_SIZE_16)
          
                For Each Style4 In Array(TEXT_RED, TEXT_BLUE, 0)
              
                    For Each Style5 In Array(TEXT_CENTER, 0)
              
                        StyleToBB Style1, Style2, Style3, Style4, Style5
                      
                    Next
                Next
            Next
        Next
    Next
End Sub

Private Sub StyleToBB(ParamArray Styles())
  
    'ActiveDocument.Range.Select
    'Selection.WholeStory
  
    Dim Style, BB_Beg$, BB_End$, BB_Beg_Concat$, BB_End_Concat$
  
    With Selection.Find
  
        .ClearFormatting
  
        For Each Style In Styles
      
            BB_Beg = ""
            BB_End = ""
      
            Select Case CLng(Style)
          
                Case TEXT_BOLD
                    .Font.BOLD = True
                    .Replacement.Font.BOLD = False
                    BB_Beg = TAG.BOLD.BEG
                    BB_End = TAG.BOLD.END
      
                Case TEXT_ITALIC
                    .Font.ITALIC = True
                    .Replacement.Font.ITALIC = False
                    BB_Beg = TAG.ITALIC.BEG
                    BB_End = TAG.ITALIC.END
              
                Case TEXT_SIZE_10
                    .Font.Size = 10
                    .Replacement.Font.Size = DEFAULT_SIZE
                    BB_Beg = TAG.TEXT_SIZE_10.BEG
                    BB_End = TAG.TEXT_SIZE_10.END
              
                Case TEXT_SIZE_12
                    .Font.Size = 12
                    .Replacement.Font.Size = DEFAULT_SIZE
                    BB_Beg = TAG.TEXT_SIZE_12.BEG
                    BB_End = TAG.TEXT_SIZE_12.END
              
                Case TEXT_SIZE_14
                    .Font.Size = 14
                    .Replacement.Font.Size = DEFAULT_SIZE
                    BB_Beg = TAG.TEXT_SIZE_14.BEG
                    BB_End = TAG.TEXT_SIZE_14.END
                  
                Case TEXT_SIZE_16
                    .Font.Size = 16
                    .Replacement.Font.Size = DEFAULT_SIZE
                    BB_Beg = TAG.TEXT_SIZE_16.BEG
                    BB_End = TAG.TEXT_SIZE_16.END
                  
                Case TEXT_RED
                    .Font.Color = wdColorRed
                    .Replacement.Font.Color = wdColorAutomatic
                    BB_Beg = TAG.COLOR_RED.BEG
                    BB_End = TAG.COLOR_RED.END
                  
                Case TEXT_BLUE
                    .Font.Color = wdColorBlue
                    .Replacement.Font.Color = wdColorAutomatic
                    BB_Beg = TAG.COLOR_BLUE.BEG
                    BB_End = TAG.COLOR_BLUE.END
              
                Case TEXT_CENTER
                    .ParagraphFormat.Alignment = wdAlignParagraphCenter
                    .Replacement.ParagraphFormat.Alignment = wdAlignParagraphLeft
                    BB_Beg = TAG.POS_CENTER.BEG
                    BB_End = TAG.POS_CENTER.END
              
            End Select
          
            If Style <> DEFAULT_SIZE Then
          
                BB_Beg_Concat = BB_Beg & BB_Beg_Concat$
                BB_End_Concat = BB_End_Concat & BB_End
              
            End If
          
        Next
      
        .Replacement.Text = BB_Beg_Concat & "^&" & BB_End_Concat
      
        .Execute FindText:="", Replace:=wdReplaceAll, Wrap:=wdFindContinue
      
    End With
  
End Sub
 
I've identified the cause of this now and I believe I have worked around it. (The fix should be running here now if you'd like to test.)
 
Back
Top Bottom