的fopen和輸入
Variables:
string line = blank
series_title = blank
folder_title = blank
int series_number = 0
box_number = 0
folder_number = 0
year = 0
do while the <end_of_document> has not been reached
input line
If the first word in the line is 「series」
store <series_number>
store the string after 「:」into the <series_title>
end if
call parse_box(rest of line)
output <series_number> <series_title> <box_number> <folder_number><folder_title> <year>
end do while
function parse_box(current line)
If the first word in the line is 「box」
store <box_number>
end if
call parse_folder(rest of line)
end function
function parse_folder(current line)
If first word is 「Folder」
store <folder_number>
end if
call parse_folder_title(rest of line)
end function
function parse_folder_title_and_year(current line)
string temp_folder_title
store everything as <temp_folder_title> until end of line
if last word in <temp_folder_title> is a year
store <year>
end if
if < temp_folder_title> is empty/blank
//use <folder_title> from before
else
<folder_title> is < temp_folder_title> minus <year>
end if
end parse_folder_title_and_year
由於命令通常只對純文本文件(東西,你可以在記事本中讀出)工作。如果要以編程方式從Microsoft Word文檔讀取,則必須將Microsoft Word 12.0對象庫(或系統上的最新版本)添加到VBAProject引用,並使用Word API打開並讀取該文檔。
Dim odoc As Word.Document
Set odoc = oWrd.Documents.Open(Filename:=DocumentPath, Visible:=False)
Dim singleLine As Paragraph
Dim lineText As String
For Each singleLine In ActiveDocument.Paragraphs
lineText = singleLine.Range.Text
'Do what you've gotta do
Next singleLine
單詞沒有「行」的概念。您可以閱讀文本範圍,段落和句子。試驗並找出最適合在可管理塊中獲取輸入文本的內容。
這個答案缺乏「oWrd」的定義, – jumpjack