Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word ConvertToTable Method Won't Wrap Table To Next Page

Status
Not open for further replies.

ACH381

Technical User
Apr 3, 2002
49
US
I am using the ConvertToTable method in Word VBA to convert a tab and carriage return delimited text string into a table. This works very well, except when I have a lot of rows of data in the string to convert. When there is a lot of text and the table should continue on the next page the method breaks. Instead of wrapping the table to the next page or stopping with an abridged table on the original page, the table is either created and not displayed or not created at all. Has anyone got an idea on what could be happening here and how to fix it?

Here is the section of the script that is using the .ConvertToTable method.
'-----------------------
With Selection
.InsertAfter CTL
Set objTable = .ConvertToTable (Separator:=wdSeparateByTabs, AutoFit:=True, defaulttablebehavior:=wdWord9TableBehavior)
DoEvents
With objTable
.Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Range.Cells.VerticalAlignment = wdCellAlignVerticalCenter
.Columns(3).PreferredWidth = InchesToPoints(1.8)
.Columns(2).PreferredWidth = InchesToPoints(2.8)
.Columns(1).PreferredWidth = InchesToPoints(3.1)
.Rows.Add(.Rows(1)).HeadingFormat = True
.Rows.Add(.Rows(1)).HeadingFormat = True
.Rows(1).Cells.Merge
With .Cell(1, 1).Range
.Font.Bold = True
.Text = "CONTACT NUMBERS (In Case of Emergency):"
End With
.Rows(2).Range.Font.Bold = True
.Cell(2, 1).Range.Text = "AGENCY NAME / TITLE"
.Cell(2, 2).Range.Text = "NAME"
.Cell(2, 3).Range.Text = "PHONE NUMBER"
End With
DoEvents
End With
'-------------------------------------

 


Hi,

Can you convert this text to your spec. from the Word Menu?

Turn on the nacro recorder and do it so it works.

My macro worked!

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top