下列代码可以精简吗?盼高手指点!
CLOSE
DATABASES
CLEAR
ALL
cPath=ADDBS(JUSTPATH(SYS(16)))
SET
DEFAULT
TO
(cPath)
USE
kb20190101
ALIAS
kb
IN
0
USE
jsrkb20190101
ALIAS
jsrkb
IN
0
PUBLIC
cxkmc , i, j , m , n , cjsxm
wjm=cpath+"mtkbmb.doc" &&模板文件
*!* 生成星期一至星期五学校日课总表
FOR
m=1
TO
5
wordApp=CREATEOBJECT("word.Application")
wordApp.visible=.t.
cStr=SUBSTR("一二三四五",1+(m-1)*2,2)
wordTable=wordApp.Application.Documents.Open(wjm)
cFileName=cPath+"学校日课总表[星期"+cStr+"]"+".doc"
wordApp.ActiveDocument.Content.Find.Execute('AB',.F.,.F.,.F.,.F.,.F.,.F.,.F.,.F.,'&cStr',2)
SELECT
kb
FOR
i=m*6-3
TO
m*6+2
FOR
j=4
TO
RECCOUNT()+3
GO
j - 3
&& 对课表进行指针定位(班级定位)
cxkmc=ALLTRIM(EVALUATE(FIELD(i)))
SELECT
jsrkb
FOR
n=3
TO
FCOUNT("jsrkb")
GO
j - 3
IF
FIELD(n)=cxkmc
cjsxm=ALLTRIM(EVALUATE(FIELD(n)))
cZdm=cxkmc+"["+cjsxm+"]"
IF
LEN(cZdm)>12
wordTable.Tables.item(1).Cell(j,i-6*(m-1)).Range.font.size=9
ENDIF
wordTable.Tables.item(1).Cell(j,i-6*(m-1)).Range.Text=cZdm
ENDIF
ENDFOR
SELECT
kb
ENDFOR
ENDFOR
*!* 将单元格中学科设置为宋体、粗体、10号字,任课教师姓名设置为楷体、9号字
wordApp.ActiveDocument.Tables(1).Cell(4, 3).Select
wordApp.Selection.MoveRight(3,71,1)
wordApp.Selection.Font.Name = "宋体"
wordApp.Selection.Font.Size = 10
wordApp.Selection.Font.Bold = .t.
do
While
wordApp.Selection.Find.Execute('[')
wordApp.Selection.MoveRight(3, 1, 1)
wordApp.Selection.Font.Name = "楷体"
wordApp.Selection.Font.Size = 9
wordApp.Selection.Font.Bold = .f.
wordApp.Selection.MoveRight(3, 1, 0)
enddo
*!* 将一二年级单元格中包含“自习1”和“自习2”的学科设为9号字
wordApp.ActiveDocument.Tables(1).Cell(4, 3).Select
wordApp.Selection.MoveRight(3, 23, 1)
do
While
wordApp.Selection.Find.Execute('自习')
wordApp.Selection.MoveRight(3, 1, 1)
wordApp.Selection.Font.Size = 9
wordApp.Selection.MoveRight(3, 1, 0)
enddo
*!* 保存退出
wordApp.Documents(1).SaveAs(cFileName)
wordApp.Documents.Close
&& 关闭工作区
wordApp.QUIT
RELEASE
wordApp
ENDFOR
RETURN