none
some mistakes in macro RRS feed

  • Question

  • I have found a macro to select all of the tables in Word, but I want it to convert all of the tables to texts. Now I put the macro behind it but failed. Could you please help me? I do need your help.

    Selection.Cut
        Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst
        Selection.Paste
        Dim mytable As Table
        For Each mytable In ActiveDocument.Tables
        mytable.Range.Editors.Add wdEditorEveryone
     Next
        ActiveDocument.SelectAllEditableRanges (wdEditorEveryone)
        ActiveDocument.DeleteAllEditableRanges (wdEditorEveryone)

       

    I add a macro Below. 

    Selection.Rows.ConvertToText Separator:=wdSeparateByParagraphs, _
            NestedTables:=True

    End Sub

    Monday, December 3, 2018 4:10 PM

Answers

  • Hi Rainbow,

    If you convert all the tables in Word to texts, you do not need to select all the tables and use the following code directly:

    Sub TablesToText()
    
        Dim tbl As Table
    
        for Each tbl In ActiveDocument.Tables
    
            tbl.ConvertToText
    
            Separator:= wdSeparateByTabs
    
        Next tbl
    
        Set tbl = Nothing
    
    End Sub

    Please refer to the following link:

    How To Convert Multiple Tables To Text In Word?

    Best Regards,

    Bruce


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, December 4, 2018 6:52 AM
    Moderator
  • Hi Bruce, 

    I've solved this issue. Thanks anyway. Have a nice day! @v@

    This is the code below:

    Sub convert()
    '
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
    tbl.ConvertToText Separator:=wdSeparateByParagraphs, _
            NestedTables:=True
      Next tbl
        Set tbl = Nothing
        Set tbl = Nothing
    End Sub

    Best Regard,

    Rainbow

    • Marked as answer by Rainbow Walker Wednesday, December 5, 2018 5:13 AM
    Wednesday, December 5, 2018 5:00 AM

All replies

  • Hi Rainbow,

    If you convert all the tables in Word to texts, you do not need to select all the tables and use the following code directly:

    Sub TablesToText()
    
        Dim tbl As Table
    
        for Each tbl In ActiveDocument.Tables
    
            tbl.ConvertToText
    
            Separator:= wdSeparateByTabs
    
        Next tbl
    
        Set tbl = Nothing
    
    End Sub

    Please refer to the following link:

    How To Convert Multiple Tables To Text In Word?

    Best Regards,

    Bruce


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, December 4, 2018 6:52 AM
    Moderator
  • Hi Bruce. Much obliged! It works so well. By the way, in the table my title aligns center and some words align justify,but after converting they all align left edges. Could you please help me solve this issue? Thanks a lot. @v@

    Best Regards,

    Rainbow





    Tuesday, December 4, 2018 1:02 PM
  • Hi Rainbow,

    You could select the converted title text, and then execute the following code:

    Selection.Paragraphs.Alignment = 1

    Best Regard,

    Bruce


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, December 5, 2018 3:10 AM
    Moderator
  • Hi Bruce, 

    I've solved this issue. Thanks anyway. Have a nice day! @v@

    This is the code below:

    Sub convert()
    '
    Dim tbl As Table
    For Each tbl In ActiveDocument.Tables
    tbl.ConvertToText Separator:=wdSeparateByParagraphs, _
            NestedTables:=True
      Next tbl
        Set tbl = Nothing
        Set tbl = Nothing
    End Sub

    Best Regard,

    Rainbow

    • Marked as answer by Rainbow Walker Wednesday, December 5, 2018 5:13 AM
    Wednesday, December 5, 2018 5:00 AM
  • Hi Reinbow,

    Please remember to mark the replies as answers if they helped. Please help us close the thread.

    Thank you for understanding! If you have any question, or update, please feel free to let me know.

    Best Regards,

    Bruce


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, December 5, 2018 5:07 AM
    Moderator