FORMATION COLUMNS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to take a srting of data and break it apart by columns and only 7
characters per column. Is this something that is posible?
 
You can change any group of text to columns by using Word's convert text
feature, however, you can only convert to a specific width in Word, not a
number of characters. [Table...|Convert...|Text to table...]

It might be easier to do your conversion in Excel. You can paste your string
of data into a cell and then use the [Data...|Text to columns...] buttons.
You would need to specify "Fixed width" rather than "Delimited" then [Next>]
and physically move the break lines between your columns to points 7, 14, 21,
28, 35, and so on, on the Data preview graph. you can drag extra lines off
the scale. This will separate your data every 7 characters even if there are
spaces, commas or other characters.

Highlight your new columns and you can paste into Word or imbed the excel
table into your document.
kathy
 
Gosh, I don't know why you would want to do this, but I agree with Kathy that
Excel would be an easier environment to do this feat. You can do it inside MS
Word by parsing the text with a Do While... Loop and adding in the commas
every 7 characters. I would do is something like this:

Sub test()
Dim ii As Long, xx As String, yy As String, myRange As Range
Set aDoc = ActiveDocument
Set myRange = aDoc.Range(Start:=aDoc.Paragraphs(1).Range.Start,
End:=aDoc.Paragraphs(1).Range.End)
myRange.ConvertToTable Separator:=wdSeparateByParagraphs
ii = Len(myRange)
xx = myRange
myRange.Delete
Do While ii > 0
If ii < 7 Then
yy = yy & xx
ii = 0
Else
yy = yy & Left(xx, 7) & ", "
ii = ii - 7
xx = Right(xx, ii)
End If
Loop

With Selection
.Collapse
.InsertBefore yy
End With
Set myTable = _
Selection.ConvertToTable(Separator:=wdSeparateByCommas, _
Format:=wdTableFormatList1)
End Sub

Good luck... With the above I ended up taking a 229 character paragraph and
separating it into skinny little columns, each with 7 lined up characters.
Kind of ugly, but it seems to be what you want. 8^)

Cheers,
Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top