如何在word表格第21行插入分页符
我想word表格每页打印20条记录,如何在表格第21行、41行、61行...... 强制插入分页符,vfp代码怎样写,请高手赐教,万分感谢!!!
teacher.rar
(1.94 KB)
在下列程序哪里写上分页代码?
fn=getfile("dbf")
use "&fn"
IF EMPTY(ALIAS())
MessageBox( "当前工作区没有打开工作表!",48,"不能生成表格")
ENDIF
WAIT "正在访问 Word 软件……" WINDOW NOWAIT
WordApp=CREATEOBJECT("Word.application") &&访问WORD
If Type("WordApp")#"O"
WAIT CLEAR
MessageBox( "访问Word失败!请检查你的系统是否正确安装 Word 软件!",48,"没有安装Word")
RETURN
ENDIF
WAIT "正在生成表格……" WINDOW NOWAIT
WordApp.Visible =.t.
WordApp.Documents.Add
*WordApp.ActiveDocument.PageSetup.PageWidth=18.4/0.035 &&设置页宽
*WordApp.ActiveDocument.PageSetup.PageHeight=26/0.035 &&设置页高
WordApp.ActiveDocument.PageSetup.LinesPage = 35 &&设置每页打印行数
WordApp.Documents(1).Range.Text=ALIAS()+"一览表"
WordApp.Documents(1).Range.Font.Size= 15
WordApp.Documents(1).Range.Font.Name="黑体"
WordApp.Documents(1).Range.Paragraphs.Alignment= 1
WordAppRang=WordApp.Documents(1).Range(LENC(WordApp.Documents(1).Range.Text)-1,LENC(WordApp.Documents(1).Range.Text)-1)
WordTable=WordApp.Documents(1).Tables.Add(WordAppRang,RECCOUNT()+1,FCOUNT())
WordTable.Range.Paragraphs.Alignment= 0
WordTable.Range.Font.Name="宋体"
WordTable.Range.Font.Size=10
WordTable.Borders.Enable=1
*WordTable.Borders(1).LineWidth = 12
*WordTable.Borders(2).LineWidth = 12
*WordTable.Borders(3).LineWidth = 12
*WordTable.Borders(4).LineWidth = 12
*WordTable.Rows(1).Borders(3).LineWidth = 12
WordTable.Borders.OutsideLineWidth=12
WordTable.Rows(1).Range.Font.Bold=.t.
WordTable.Rows(1).Cells.VerticalAlignment= 1
WordTable.Rows(1).Range.Paragraphs.Alignment = 1
WordTable.Rows(1).HeadingFormat=.t.
FOR i=1 TO FCOUNT()
WordTable.Cell(1,i).Range.Text=FIELD(i)
FOR k=2 TO RECCOUNT()+1
GO k-1
WordCellText=EVALUATE(FIELD(i))
DO CASE
CASE ISNULL(WordCellText)
WordCellText=""
CASE TYPE("WordCellText")="N"
CASE TYPE("WordCellText")="D"
WordCellText=DTOC(WordCellText)
CASE TYPE("WordCellText")="T"
WordCellText=TTOC(WordCellText)
CASE TYPE("WordCellText")="M"
WordCellText=TRIM(WordCellText)
WordCellText=STRTRAN(WordCellText,CHR(13),' ')
CASE TYPE("WordCellText")="L"
WordCellText=IIF(WordCellText,".T.",".F.")
CASE EMPTY(WordCellText)
WordCellText=" "
OTHERWISE
* WordCellText=""
ENDCASE
IF EMPTY(WordCellText) OR ISNULL(WordCellText)
WordCellText=" "
ENDIF
WordTable.Cell(k,i).Range.Text=WordCellText
endfor
WordTable.Columns(i).AutoFit
endfor
* 下面为页面设置
WordApp.ActiveDocument.PageSetup.PaperSize=7
WordApp.ActiveDocument.PageSetup.Orientation=0 &&页面竖放 0-竖放 1-横放
*WordTable.Rows.HorizontalPosition=-999995 &&表格水平居中
WordApp.ActiveDocument.PageSetup.TopMargin=22.0*2.835 &&设置上边距
WordApp.ActiveDocument.PageSetup.BottomMargin=22.0*2.835 &&设置下边距
WordApp.ActiveDocument.PageSetup.LeftMargin=19.0*2.835 &&设置左边距
WordApp.ActiveDocument.PageSetup.RightMargin=19.0*2.835 &&设置右边距
WordApp.ActiveDocument.PageSetup.VerticalAlignment=0 &&页面对齐方式 0-上 1-中 2-下
WordApp.Documents(1).SaveAs("E:\My.doc") &&自动保存文件
RELEASE WordApp
WAIT CLEAR
MessageBox( "生成Word文件完毕,文件位置 E:\My.doc !",64,"完毕")
RETURN