程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 源代碼-哪位大神可以幫我講解一下這個vb程序啊 ,感激不盡

源代碼-哪位大神可以幫我講解一下這個vb程序啊 ,感激不盡

編輯:編程綜合問答
哪位大神可以幫我講解一下這個vb程序啊 ,感激不盡

With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.8)
.BottomMargin = InchesToPoints(0.8)
.LeftMargin = InchesToPoints(0.8)
.RightMargin = InchesToPoints(0.8)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With

Selection.Sections(1).Headers(1).PageNumbers.Add PageNumberAlignment:= _
wdAlignPageNumberRight, FirstPage:=True

Dim quote As String
Dim Keyword As String
Dim j As Integer
quote = """"
Dim found_key As Boolean
Dim startSearch As Long
Dim endSearch As Long

Close #1
Open "C:\Users\shuqi\Desktop\新建文本文檔.txt" For Input As #1

Set myRange = ActiveDocument.Content

j = 0
Do While Not EOF(1) ' Loop until end of file.
Set myRange = ActiveDocument.Content
endSearch = myRange.End

Input #1, Keyword

j = 0

With myRange.Find
.Text = Keyword
.Forward = True
.MatchWholeWord = True
.MatchCase = False
End With

While myRange.Find.Execute
myRange.Collapse wdCollapseEnd
Set myIndexEntry = myRange.Fields.Add(myRange, Type:=wdFieldIndexEntry, _
Text:=quote & Keyword & quote)

startSearch = myRange.End
startSearch = startSearch + 7
Set myRange = ActiveDocument.Content
myRange.Start = startSearch

If startSearch = endSearch - 1 Then
GoTo skip_while
End If

With myRange.Find
.Text = Keyword
.Forward = True
.MatchWholeWord = True
.MatchCase = False
End With

' this code is because I had a loop here
j = j + 1
If j = 300 Then
myRange.Bold = True
Exit Do
End If

Wend

skip_while:

Loop

Close #1 ' Close file.

myRange.Start = 0
myRange.End = 0
With ActiveDocument
.Indexes.Add Range:=myRange, HeadingSeparator:= _
wdHeadingSeparatorNone, Type:=wdIndexIndent, RightAlignPageNumbers:= _
True, NumberOfColumns:=1, IndexLanguage:=wdEnglishUS
.Indexes(1).TabLeader = wdTabLeaderDots

End With

End Sub

最佳回答:


如果你的英語老師死得早,你也可以請教下英文詞典。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved