脱线布偶 2015-01-09 02:37 采纳率: 46.2%
浏览 2383
已采纳

哪位大神可以帮我讲解一下这个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

  • 写回答

4条回答 默认 最新

  • threenewbee 2015-01-09 02:56
    关注

    如果你的英语老师死得早,你也可以请教下英文词典。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题