MasteringVFP/13/5

出自VFP Wiki

(修訂版本間差異)
跳轉到: 導航, 搜尋
(revert)
 
第56行: 第56行:
  loWord.visible=-1
  loWord.visible=-1
</pre>
</pre>
-
[http://www.hg-fix.com/ 数据恢复]
 
-
[http://www.hg-fix.com/ 硬盘数据恢复]
 
-
[http://www.hg-fix.com/ 磁带数据恢复]
 
-
[http://www.hg-fix.com/ raid数据恢复]
 
-
[http://www.hg-fix.com/ 磁盘阵列数据恢复]
 
-
[http://www.hg-fix.com/diskrecover.htm 数据恢复]
 
-
[http://www.hg-fix.com/taperecover.htm 数据恢复]
 
-
[http://www.hg-fix.com/raidrecover.htm 数据恢复]
 
-
[http://www.hg-fix.com/ 数据修复]
 
-
[http://www.hg-fix.com/ 硬盘数据修复]
 
-
[http://www.hg-fix.com/ 磁带数据修复]
 
-
[http://www.hg-fix.com/ raid数据修复]
 
-
[http://www.hg-fix.com/diskrecover.htm 数据修复]
 
-
[http://www.hg-fix.com/raidrecover.htm 数据修复]
 
-
[http://www.hg-fix.com/taperecover.htm 数据修复]
 
-
[http://www.hg-fix.com/ 磁盘阵列数据修复]
 

在2005年4月18日 (一) 01:47的最新修訂版本

實例應用1-在VFP中使用 Word 輸出報表

我們可以在VFP中呼叫COM,例如WORD或ADO。因此可以透過ADO與SQL server連線,做資料的處理,省去了odbc的設定。

以下以WORD為例。先由dbf檔建立word的表格,再以表格與檔案做合併列印。這樣做比用vfp的報表麻煩,但是可以給使用者較大的彈性。

 * 建立資料檔
 loWord = CreateObject('Word.Application')
 with loword
   IF thisform.chkProgress.value=1
      .visible = -1
   ENDIF
   .Documents.Add
   .ActiveDocument.Tables.Add(.Selection.Range, lnCnt+1, 2)
  with .Selection
    .TypeText ("系主任姓名")	
    .MoveRight(12) && Unit:=wdCell
    .TypeText ("件數")
    go top in rectemp
    For I = 1 to lnCnt
       .MoveRight (12) && Unit:=wdCell
       .TypeText (alltrim(rectemp.inst_name)+' '+ ;
                  rectemp.name+rectemp.title)
       .MoveRight (12) && Unit:=wdCell
       .TypeText (alltrim(str(rectemp.dep_cnt)))
       skip in rectemp
    EndFor
   endwith
    .ChangeFileOpenDirectory(fullpath('.'))
    .ActiveDocument.SaveAs("系主任姓名.doc")
    .ActiveDocument.Close
 endwith    

 * 開啟合併檔
 loWord.Documents.open('命題函 (系主任).doc')
   IF thisform.chkProgress.value=1
      loWord.visible = -1
   ENDIF
 * loDoc = loWord.ActiveDocument
 With loWord.ActiveDocument.MailMerge
     .Destination = 0 && wdSendToNewDocument
     .MailAsAttachment = 0 &&False
     .MailAddressFieldName = ""
     .MailSubject = ""
     .SuppressBlankLines = -1 && True
     With .DataSource
          .FirstRecord = 1 && wdDefaultFirstRecord
          .LastRecord = -16 && wdDefaultLastRecord
     EndWith
     .Execute(-1) && Pause:=True
 EndWith
 loWord.Windows("命題函 (系主任).doc").Activate
 loWord.ActiveWindow.Close
 loWord.Move(21,24) && Left:=21, Top:=24 
 loWord.visible=-1