全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1539
推到 Plurk!
推到 Facebook!

请问如何用delphi得到doc文件的统计信息(如:页数,行数等等)

答題得分者是:ha0009
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-22 10:22:15 IP:61.149.xxx.xxx 未訂閱
用delphi得到doc文件的统计信息(如:页数,行数,段落数,字数,字符数,字符等等)
ha0009
版主


發表:16
回覆:507
積分:639
註冊:2002-03-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-22 16:14:04 IP:61.30.xxx.xxx 未訂閱
你好: 下列程式供你參考 < class="code"> function BuiltInDocumentProperties (Doc : TWordDocument; Const PropertieName : LongWord) : Variant; begin result := OleVariant(Doc.DefaultInterface).BuiltInDocumentProperties[PropertieName].Value; end; procedure TForm1.Button1Click(Sender: TObject); begin memo1.Lines.Add(format ('%s : %s', ['頁數', BuiltInDocumentProperties (WordDocument1, wdPropertyPages)])); memo1.Lines.Add(format ('%s : %s', ['行數', BuiltInDocumentProperties (WordDocument1, wdPropertyLines)])); memo1.Lines.Add(format ('%s : %s', ['段落數', BuiltInDocumentProperties (WordDocument1, wdPropertyParas)])); memo1.Lines.Add(format ('%s : %s', ['字數', BuiltInDocumentProperties (WordDocument1, wdPropertyWords)])); memo1.Lines.Add(format ('%s : %s', ['字元數', BuiltInDocumentProperties (WordDocument1, wdPropertyCharacters)])); memo1.Lines.Add(format ('%s : %s', ['字元數(含空白)', BuiltInDocumentProperties (WordDocument1, wdPropertyCharsWSpaces)])); memo1.Lines.Add(format ('%s : %s', ['位元組數', BuiltInDocumentProperties (WordDocument1, wdPropertyBytes)])); end; PS : PropertieName 常數有下列選擇 wdPropertyAppName wdPropertyAuthor wdPropertyBytes wdPropertyCategory wdPropertyCharacters wdPropertyCharsWSpaces wdPropertyComments wdPropertyCompany wdPropertyFormat wdPropertyHiddenSlides wdPropertyHyperlinkBase wdPropertyKeywords wdPropertyLastAuthor wdPropertyLines wdPropertyManager wdPropertyMMClips wdPropertyNotes wdPropertyPages wdPropertyParas wdPropertyRevision wdPropertySecurity wdPropertySlides wdPropertySubject wdPropertyTemplate wdPropertyTimeCreated wdPropertyTimeLastPrinted wdPropertyTimeLastSaved wdPropertyTitle wdPropertyVBATotalEdit wdPropertyWords 發表人 - ha0009 於 2003/08/22 16:17:26
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-25 12:38:34 IP:61.149.xxx.xxx 未訂閱
thank you
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-08-25 13:30:54 IP:61.149.xxx.xxx 未訂閱
怎么得到一个已存在的word文档的上述信息!
ha0009
版主


發表:16
回覆:507
積分:639
註冊:2002-03-16

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-08-25 13:53:34 IP:61.30.xxx.xxx 未訂閱
你好: 何謂 "已存在" < > 不管是載入檔案還是新增檔案,都是使用相同的方式呀< >
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-08-25 14:13:50 IP:61.149.xxx.xxx 未訂閱
你好!怎样才能统计載入檔案的信息!请具体些!谢谢!
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-08-25 16:24:44 IP:61.149.xxx.xxx 未訂閱
"已存在"就是已经在硬盘上存在的word文档.请问如何得到已经在硬盘上存在的word文档的信息!
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-08-25 16:29:26 IP:61.149.xxx.xxx 未訂閱
怎样才能把"已经存在的word文档"与WordDocument1对象建立关系.
ha0009
版主


發表:16
回覆:507
積分:639
註冊:2002-03-16

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-08-25 16:50:10 IP:61.30.xxx.xxx 未訂閱
你好: 釣竿都給你囉,加油吧 < class="code"> procedure TForm1.OpenDoc; var FileName: OleVariant; ConfirmConversions: OleVariant; ReadOnly: OleVariant; AddToRecentFiles: OleVariant; PasswordDocument: OleVariant; PasswordTemplate: OleVariant; Revert: OleVariant; WritePasswordDocument: OleVariant; WritePasswordTemplate: OleVariant; Format: OleVariant; Encoding: OleVariant; Visible: OleVariant; begin WordDocument1.ConnectTo( WordApplication1.Documents.Open ( FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible ) ); end; PS : 語法 1:開啟指定的文件並將其新增至 Documents 集合 (Documents collection)。傳回一個 Document 物件 (Document object)。 語法 2:開啟指定的物件。當套用於 Subdocument 物件 (Subdocument object) 或 RecentFile 物件 (RecentFile object) 時,語法 2 傳回一個 Document 物件。 語法 1 expression.Open(FileName, ConfirmConversions, ReadOnly, AddToRecentFiles, PasswordDocument, PasswordTemplate, Revert, WritePasswordDocument, WritePasswordTemplate, Format, Encoding, Visible) 語法 2 expression.Open expression 語法 1:必要的運算式,它會傳回一個 Documents 物件 (Documents object)。 語法 2:必要的運算式,它會傳回一個 OLEFormat、 RecentFile、 Subdocument、或 Version 物件。 FileName 必要的 Variant 資料型態。文件的名稱(路徑可被接受)。 ConfirmConversions 選擇性的 Variant 資料型態。如果文件不是 Microsoft Word 格式,且該屬性為 True,則顯示 [轉換檔案] 對話方塊。 ReadOnly 選擇性的 Variant 資料型態。True 則將文件以唯讀方式開啟。 AddToRecentFiles 選擇性的 Variant 資料型態。True 則將檔案名稱新增到 [檔案] 功能表底部,最近使用過的檔案清單。 PasswordDocument 選擇性的 Variant 資料型態。開啟此文件時所需的密碼。 PasswordTemplate 選擇性的 Variant 資料型態。開啟此範本時所需的密碼。 Revert 選擇性的 Variant 資料型態。如果 Name 是開啟的文件檔名時,控制會發生的動作。True 則放棄對此文件所作,尚未儲存的變更,並重新開啟此檔案。False 則啟動開啟的文件。 WritePasswordDocument 選擇性的 Variant 資料型態。儲存對文件所做的變更時,所需的密碼。 WritePasswordTemplate 選擇性的 Variant 資料型態。進行儲存對範本所做的變更時,所需的密碼。 Format 選擇性的 Variant 資料型態。開啟文件時使用的檔案轉換程式。可為下列 WdOpenFormat 常數之一:wdOpenFormatAllWord、wdOpenFormatAuto、wdOpenFormatDocument、wdOpenFormatEncodedText、wdOpenFormatRTF、wdOpenFormatTemplate、wdOpenFormatText、wdOpenFormatUnicodeText、或wdOpenFormatWebPages。預設值為 wdOpenFormatAuto。 若要指定外部檔案格式,請將 OpenFormat 屬性套用到 FileConverter 物件來決定使用此引數的值。 Encoding 選擇性的 Variant 資料型態。當您檢視儲存的文件時,Microsoft Word 所使用的文件編碼(字碼頁或字元組)。可為任何有效的 MsoEncoding 常數。有關有效的 MsoEncoding 常數清單,請參閱 Visual Basic 編輯器的物件瀏覽器。預設為系統字碼頁。可讀寫的 Long 型態。 Visible 選擇性的 Variant 資料型態。如果文件是在看得見的視窗中開啟,則為 True。預設值為 True。
reebokmonkey
一般會員


發表:44
回覆:73
積分:23
註冊:2003-08-06

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-08-26 09:16:46 IP:61.149.xxx.xxx 未訂閱
谢谢!
系統時間:2024-05-19 1:34:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!