I have Excel spreadsheet with data that I would like to put in MS Word for better presentation. I know that I can simply cut and paste the Excel cell into Ms Word as a table.
Instead, I want to be able to transfer the data in each cell in Excel to Ms Word in form format. To accomplish this I wrote Excel macro to write data from Excel into a text file.
Sub WriteToFile()
Application.Goto reference:=Worksheets("Cases").Range("A6")
Open "c:\temp\ufos.txt" For Output As #1
k = 6
n = 116
n = n - k + 1
For i = 1 To n
nm = ActiveCell.Value
Print #1, "Name of Event: "; nm
lc = ActiveCell.Offset(0, 1).Value + ", " + ActiveCell.Offset(0, 2).Value
Print #1, "Location: "; lc
dt = ActiveCell.Offset(0, 8).Value
Print #1, "Date: "; Format(dt, "mmmm dd, yyyy")
tm = ActiveCell.Offset(0, 11).Value
Print #1, "Time: "; tm
te = ActiveCell.Offset(0, 5).Value
Print #1, "Type of Encounter: "; te
sp = ActiveCell.Offset(0, 6).Value
Print #1, "Shape: "; sp
dsc = ActiveCell.Offset(0, 12).Value
Print #1, "Description: "; dsc
ActiveCell.Offset(1, 0).Activate
Print #1,
Print #1,
Next i
Close #1
End Sub
My question now is how do I format each of the entries. For example I want to be able to bold field name.
I also want to indent each of the lines under the "Description" field.
Bookmarks