![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
I went ahead and put together the kludgy version...
Main code Code:
Private Sub cmdConvertToText_Click() On Error GoTo ErrorHandler If txtSeparator.Value <> "" Then Selection.Tables(1).Select Selection.Rows.ConvertToText Separator:="^", NestedTables:=True 'The ^ char is temporary. Call DoFindClean("^", (txtSeparator.Value), "0") 'Swap ^ for textbox content. 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 Code:
Sub DoFindClean(FindText As String, ReplaceText As String, WrapOrNot As String) 'This module gets called from the Text Cleaner code ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = FindText .Replacement.Text = ReplaceText .Forward = True .Wrap = WrapOrNot .MatchWildcards = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
kathir1984 | Word VBA | 2 | 12-17-2019 03:59 AM |
![]() |
Rogireus | Word VBA | 4 | 10-24-2019 05:25 AM |
Convert Text To Table: Separate text at (Other)? | tinfanide | Word VBA | 2 | 01-12-2015 05:26 AM |
![]() |
abhunter | Word | 1 | 06-11-2013 02:39 PM |
Convert graphic to text in a table | Jennifer Murphy | Word | 6 | 01-24-2013 12:56 PM |