View Single Post
 
Old 04-12-2022, 05:42 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It appears that in a regular table (where all columns align exactly) this code would have just filled one column. But if at least one row has different column width/alignment (or maybe there are merged cells) then more than one column gets the inserted text.

Can you verify that all the table cells are aligned perfectly?

PS. I would deal with the selection error a different way.
Code:
Sub aTest()
  Dim Lstr As String, aCell As Cell
  If Selection.Information(wdWithInTable) Then
    Selection.InsertColumns
    Lstr = Me.txtColLeftText
    For Each aCell In Selection.Cells
      aCell.Range.Text = Lstr
    Next aCell
    Selection.MoveRight Unit:=wdCell
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote