View Single Post
 
Old 04-16-2021, 12:21 PM
Steve Kunkel Steve Kunkel is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: May 2019
Location: Seattle area
Posts: 81
Steve Kunkel is on a distinguished road
Default multi-char separator in 'convert table to text'?

Hi Folks,

I've been experimenting with "Convert Table to Text." The below code reads the delimiter that I've put in my text box. It works fine, but if I try to use a multi-character delimiter, it only uses the first character. I figure I can add a "find and replace" to force multiple characters in there, but that would be kludgy.

Does anyone know if there's a way to allow multiple characters? I had no luck with Google.


Code:
Private Sub cmdConvertToText_Click()

On Error GoTo ErrorHandler
    If txtSeparator.Value <> "" Then
        Dim mySep As String
        mySep = txtSeparator.Value
        Selection.Rows.ConvertToText Separator:=mySep, NestedTables:=True
    Else
        Selection.Rows.ConvertToText Separator:=wdSeparateByDefaultListSeparator, NestedTables:=True
    End If
Exit Sub

ErrorHandler:
   MsgBox "Run Table Converter after clicking in a table.  Don't 'select' the table, just click in it."

End Sub
Reply With Quote