求助:无法打印
现有表单1,我想点击姓名,打印出定制的word格式报表,出现一些问题,请高手赐教,万分感谢!!!
打印.rar
(98.14 KB)
“打印”按钮代码如下:
cStuNumb=thisform.List1.value
IF EMPTY(cStuNumb)
MESSAGEBOX("请先选择在列表框中单击学生的姓名!",0+64+0,"提示信息")
ELSE
DO WriteReport WITH cStuNumb
ENDIF
PROCEDURE WriteReport
PARAMETERS cStudentNumber
#INCLUDE Wdolb.h
#DEFINE True .T.
#DEFINE False .F.
IF !USED('student')
USE student IN 0 ORDER studentno
ENDIF
SELECT student
IF PARAMETERS()=0
cStudentNumber=student.studentno
ENDIF
SEEK cStudentNumber
IF FOUND()
LOCAL loWord,loTable,lnRow,lnColumn
* loWord=createobject("word.application")
loWord=Getcominstance("word.application")
loWord.Visible=.t.
cString="学生信息报表"
WITH loWord
.Documents.add("Normal",False)
.Selection.MoveDown(wdLine,100)
WITH .Selection
.Font.Name="宋体"
.Font.Size=20
.ParagraphFormat.Alignment=wdAlignparagraphcenter
.TypeText(cString)
.TypeParagraph
ENDWITH
.Selection.Sections(1).Footers(1).PageNumbers.Add(wdAlignPageNumbercenter,True)
.Selection.Font.Size=14
.ActiveDocument.Tables.Add(.Selection.Range,1,7)
loTable=.ActiveDocument.Tables(1)
WITH loTable
.Cell(1,1).width=80
.Cell(1,2).width=45
.Cell(1,3).width=80
.Cell(1,4).width=45
.Cell(1,5).width=30
.Cell(1,6).width=45
.Cell(1,7).width=90
.Cell(1,1).Range.InsertAfter("照片")
.Cell(1,2).Range.InsertAfter("姓名")
.Cell(1,4).Range.InsertAfter("性别")
.Cell(1,6).Range.InsertAfter("学号")
.Cell(1,3).Range.InsertAfter(name)
.Cell(1,5).Range.InsertAfter(gender)
.Cell(1,7).Range.InsertAfter(studentno)
ENDWITH
.Selection.MoveDown(wdLine,100)
.ActiveDocument.Tables.Add(.Selection.Range,2,5)
loTable=.ActiveDocument.Tables(1)
WITH lcTable
FOR j=2 TO 3
.Cell(j,1).width=80
.Cell(j,2).width=70
.Cell(j,3).width=100
.Cell(j,4).width=70
.Cell(j,5).width=95
ENDFOR
.Cell(2,2).Range.InsertAfter("出生年月")
.Cell(2,3).Range.InsertAfter(borntime)
.Cell(2,4).Range.InsertAfter("入学时间")
.Cell(2,5).Range.InsertAfter(atime)
.Cell(3,2).Range.InsertAfter("所在院系")
.Cell(3,3).Range.InsertAfter(department)
.Cell(3,4).Range.InsertAfter("所学专业")
.Cell(3,5).Range.InsertAfter(major)
ENDWITH
.Selection.SelectColumn
.Selection.Cells.Merge
.Selection.MoveDown(wdLine,100)
.ActiveDocument.Tables.Add(.Selection.Range,2,4)
loTable=.ActiveDocument.Tables(1)
WITH loTable
FOR j=4 TO 5
.Cell(j,1).width=80
.Cell(j,2).width=170
.Cell(j,3).width=70
.Cell(j,4).width=95
ENDFOR
.Cell(4,1).Range.InsertAfter("学校住址")
.Cell(4,2).Range.InsertAfter(drom)
.Cell(4,3).Range.InsertAfter("寝室电话")
.Cell(4,4).Range.InsertAfter(dtelenumbe)
.Cell(5,1).Range.InsertAfter("家庭住址")
.Cell(5,2).Range.InsertAfter(address)
.Cell(5,3).Range.InsertAfter("联系电话")
.Cell(5,4).Range.InsertAfter(htelenumbe)
ENDWITH
.Selectoin.MoveDown(wdLine,100)
.ActiveDocument.Tables.Add(.Selection.Range,1,2)
loTable=.ActiveDocument.Tables(1)
WITH loTable
.Cell(6,1).width=80
.Cell(6,1).Height=60
.Cell(6,2).width=335
.Cell(6,1).Range.InsertAfter("个人特长")
.Cell(6,2).Range.InsertAfter(hobby)
ENDWITH
.Selection.Sections(1).Footers(1).PageNumbers.Add(wdAlignPageNumberCenter,True)
ENDWITH
ENDIF
return
出现错误提示后电脑无反应!
[此贴子已经被作者于2024-5-25 15:38编辑过]