| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 301 人关注过本帖
标题:求助:无法打印
只看楼主 加入收藏
王咸美
Rank: 1
等 级:新手上路
帖 子:643
专家分:3
注 册:2018-1-4
结帖率:97.33%
收藏
已结贴  问题点数:20 回复次数:6 
求助:无法打印
现有表单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编辑过]

搜索更多相关主题的帖子: WITH Tables Selection Cell add 
2024-05-25 15:36
laowan001
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:66
帖 子:1076
专家分:2628
注 册:2015-12-30
收藏
得分:5 
错误提示显示,表没有设置排序索引,那就是没有索引文件
程序中,表student应该已经打开了,否则就会在USE student IN 0 ORDER studentno这句报错了
检查是否建立了索引文件吧
2024-05-25 15:52
xs591222
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:28
帖 子:682
专家分:1299
注 册:2009-3-1
收藏
得分:5 

SEEK
改用
loca for
就不需要索引了可以定位
2024-05-25 17:06
王咸美
Rank: 1
等 级:新手上路
帖 子:643
专家分:3
注 册:2018-1-4
收藏
得分:0 
我在表单的Load属性中写入索引
INDEX ON name TAG name
每次运行表单时,都会出现 “name已经存在,改写吗?”
在表单的什么地方写上什么代码?去掉每次运行表单时的提示!盼高手指点。
2024-05-26 16:26
凝聚双眼
Rank: 2
等 级:论坛游民
帖 子:31
专家分:23
注 册:2023-12-1
收藏
得分:5 

Set Safety Off

2024-05-26 16:30
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9831
专家分:27165
注 册:2012-2-5
收藏
得分:5 
表单LOAD事件中第一行加入下面代码
set safety off

坚守VFP最后的阵地
2024-05-26 16:35
shschy
Rank: 2
等 级:论坛游民
帖 子:83
专家分:20
注 册:2022-3-13
收藏
得分:0 
请问Getcominstance函数的功能
请问Getcominstance("word.application")的功能是打开被最小化的WORD程序吗
以下是引用王咸美在2024-5-25 15:36:22的发言:现有表单1,我想点击姓名,打印出定制的word格式报表,出现一些问题,请高手赐教,万分感谢!!!“打印”按钮代码如下:cStuNumb=thisform.List1.valueIF  EMPTY(cStuNumb) MESSAGEBOX("请先选择在列表框中单击学生的姓名!",0+64+0,"提示信息")ELSE DO WriteReport WITH cStuNumbENDIFPROCEDURE WriteReportPARAMETERS cStudentNumber#INCLUDE Wdolb.h#DEFINE True .T.#DEFINE False .F.  IF !USED('student')USE student IN 0 ORDER studentno ENDIFSELECT student IF PARAMETERS()=0 cStudentNumber=student.studentnoENDIFSEEK  cStudentNumberIF 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-05-27 00:01
快速回复:求助:无法打印
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016586 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved