Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-16-2021, 02:49 PM
Steve Kunkel Steve Kunkel is offline multi-char separator in 'convert table to text'? Windows 10 multi-char separator in 'convert table to text'? Office 2019
Advanced Beginner
multi-char separator in 'convert table to text'?
 
Join Date: May 2019
Location: Seattle area
Posts: 81
Steve Kunkel is on a distinguished road
Default

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
Function
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
Note that the carret "^" is used as a placeholer... If a table happened to have one of those characters already it would mess up my system.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
multi-char separator in 'convert table to text'? Convert Text to Table kathir1984 Word VBA 2 12-17-2019 03:59 AM
multi-char separator in 'convert table to text'? vba detect first char in line and auto insert table 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
multi-char separator in 'convert table to text'? Text in table for multi-use form (online&hard copy) 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft