How do I format a text into a table format in Word using VBS in a.

P

Porchia

I am trying to update an existing VBS that uses the selection object to
generate a document. At this time it is just formatting the text as
sentences, I am needing to change the text to be formatted into table format
(rows & cols). How do I update the selection object to display the text in a
table layout?
 
J

Jonathan West

Porchia said:
I am trying to update an existing VBS that uses the selection object to
generate a document. At this time it is just formatting the text as
sentences, I am needing to change the text to be formatted into table
format
(rows & cols). How do I update the selection object to display the text
in a
table layout?

Hi Porchia

You need the ConvertToTable method of the Selection object. There are full
details and code examples in the VBA Help file.
 
P

Porchia

Here is a small part of my code. I am trying to convert only a few lines in
this selection object to a table layout. The first 2 lines stay the same but
the last 2 lines need to be in a table format. The example they have in the
VBS help is not very helpful... it shows taking the entire selection and
converting it to a table and putting it into a variable. My macro takes the
selection and puts mine into the clipboard so I can paste it into an email.
This is the only way I have found to get the form into an email.

Private Sub buildBodyPSWR()

Dim sDate As String
sDate = DTPicker1.Value

With Selection

.WholeStory
.Delete Unit:=wdCharacter, Count:=1
.Font.Name = "Arial(Western)"
.Font.Size = 9

.TypeText ("*Fields in ")
.Font.Bold = wdToggle
.TypeText ("BOLD ")
.Font.Bold = wdToggle
.TypeText ("are required.")
.Font.Bold = wdToggle
.TypeParagraph
.TypeParagraph

.TypeText ("*Desired Completion Date/Time: ")
.Font.ColorIndex = wdRed
.TypeText gblGetDay(DTPicker1.DayOfWeek) & " " & sDate & " " &
txtTime.Text
.TypeParagraph
.Font.ColorIndex = wdBlack

.TypeText ("*Phone Ext: ")
.Font.ColorIndex = wdRed
.TypeText (txtPhone.Text)
.Font.ColorIndex = wdBlack
.TypeParagraph

.TypeText ("*Host System Name: ")
.Font.ColorIndex = wdRed
.TypeText (txtSystem.Text)
.Font.ColorIndex = wdBlack
.Font.Bold = wdToggle
.TypeParagraph
.TypeParagraph

.WholeStory
.Copy

End With

End Sub
 
J

Jonathan West

A vitally important question.

Are the "last two lines" you want to convert to a table within the same
paragraph, or are they separate paragraphs?
 
P

Porchia

They are in separate paragraphs.

It looks like this now:
Remedy Change or HelpDesk ticket#:
Charge to Unit # for Batch Run: 01-0444
DB2/ORACLE Access (Yes/No): YES
Location of JCL/Script to be turned over:

Scheduling Requirements:
When to run (Month, Day, Time, etc.):
Holidays (run, skip, run next day, run previous day, etc.):
Requirement Job/File:
Successor Job/File:
Conflict Job/File:

But I need to put it in a table format instead of just text.
 

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

Top