Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Table headers/footers and layout | Page Layout | |||
Table rows where format is unalterable | New Users | |||
Stopping Save As Dialog appearing when closing a document | Microsoft Word Help | |||
Dragging table column resets | Tables | |||
ALT+SHIFT+Arrow shortcut to move table rows | Tables |