Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    wdDialogTableToText separator character (Word2000)

    Stumped again. The code below works. Place the insertion point in a table and run the macro to rebuild a table by converting to text and back again.
    I'd love to understand the ConvertTo.
    When I choose Paragraphs, Tabs or Commas I get 0, 1 or 2 as the dlga.ConvertTo value. Choosing Other yields 3 as the dlga.ConvertTo value. So far so good.
    But the darned thing seems to embed the value of the other character within the dlga.ConvertTo.

    Try using an exclamation mark as the separator. You'll be told that :
    dlga.ConvertTo=3 (OK) and
    Asc(dlga.ConvertTo) is 51
    whereas
    ASC("!") is 33.

    The ConvertTo must have something within it that can be accessed by the .ConvertToTable to determine the actual character chosen, but that value appears to be withheld from the VBAer. In my case I can't record or store the actual character being used (for future reference of use to the end-user). I can, however, preserve the setting (in MyVar) for future use in table conversions (Thanks again, Rory!)

    <pre>Sub TEST()
    ' Rebuild an entire table.
    Dim rng As Range
    Set rng = Selection.Tables(1).Range
    rng.Select
    Dim dlga As Dialog
    Set dlga = Dialogs(wdDialogTableToText)
    With dlga
    If .Display = -1 Then
    Set rng = rng.Tables(1).Rows.ConvertToText(dlga.ConvertTo)
    Dim myVar
    myVar = dlga.ConvertTo
    Debug.Print dlga.ConvertTo
    Debug.Print Asc(dlga.ConvertTo)
    rng.ConvertToTable (dlga.ConvertTo)
    ''
    Set rng = rng.Tables(1).Rows.ConvertToText(myVar)
    Debug.Print myVar
    Debug.Print Asc(myVar)
    rng.ConvertToTable (myVar)
    '''
    Else
    End If
    End With
    End Sub</pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: wdDialogTableToText separator character (Word2000)

    The ConvertTo argument of the dialog and the Separator argument of ConvertToTable and ConvertToText is simply an Enum with values 0, 1, 2 or 3. It does NOT store the "other" character. This is stored in Application.DefaultTableSeparator. When the user specifies an "other" character, this sets Application.DefaultTableSeparator. Next time you call ConvertToTable and ConvertToText with Separator:=wdSeparateByDefaultListSeparator (=3) or without specifying Separator, the DefaultTableSeparator character will be used.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: wdDialogTableToText separator character (Word2

    > This is stored in Application.DefaultTableSeparator
    Ah! Much obliged. I see it now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •