Reply
 
Thread Tools Display Modes
  #1   Report Post  
yaron
 
Posts: n/a
Default rows of table breaks when i save the document

hello
i'm trying to make a program that creates a report in MS WORD only.
i need to create tables and fill them with information and having one line
between every table,the size of a table suppose to be 7X4 (7 rows, 4 columns).

the problem is when i create tables is that the rows split between pages,
for example :
if there are 4 tables in page 1 in size of 7X4 , and there is only enough
room on the page for half of the fifth table so the rows split ,2 rows are in
page 1 and 5 rows are in page 2.

so...i found some properties to solve this problem but if you run the code
below and set a breakpoing before the SaveAs method , you will see there is
no split, after you save the document and open it you will see the rows are
split again.....please tell me how do i fix that problem

here is the code: ( i know it's badly written but it's a test code,if
someone can give me some tips how to improve it i would be thankful )

Private Sub Command1_Click()
Dim objword As Word.Application
Dim objdoc As New Document

Set objword = New Word.Application
Set objdoc = objword.Documents.Add
objdoc.Activate

Dim i As Integer
Dim oTable As Table

i = 1

For i = 1 To 12
If i = 1 Then
objdoc.SaveAs "c:\report.doc"
End If

'create new table
Set oTable =
objword.ActiveDocument.Range.Tables.Add(objword.Ac tiveDocument.Application.Selection.Range, 9, 4, wdWord9TableBehavior, wdAutoFitFixed)
'set properties (this properties suppose to fix the split problem)
oTable.AllowPageBreaks = False
oTable.Rows.AllowBreakAcrossPages = False
oTable.Rows.HeadingFormat = True
objdoc.Paragraphs.PageBreakBefore = False
With objword.ActiveDocument.Range.ParagraphFormat
..WidowControl = True
..KeepWithNext = False
..KeepTogether = True
..PageBreakBefore = False
..NoLineNumber = True
..Hyphenation = True
End With

'move to end
oTable.Cell(9, 4).Select
objword.ActiveDocument.Range.Application.Selection .MoveDown wdLine, 2
'add paragraph
objword.ActiveDocument.Range.Application.Selection .TypeParagraph
Next

'cleanup
Set oTable = Nothing

objdoc.SaveAs "c:\report.doc"
objdoc.Close
objword.Quit
MsgBox "done"

End Sub
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM
Table rows where format is unalterable Hokum New Users 1 January 14th 05 03:49 PM
Stopping Save As Dialog appearing when closing a document N. Cotton Microsoft Word Help 1 January 13th 05 09:46 PM
Dragging table column resets Sedonakids Tables 0 January 12th 05 01:11 AM
ALT+SHIFT+Arrow shortcut to move table rows Nicola Tables 3 December 16th 04 09:58 PM


All times are GMT +1. The time now is 03:40 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"