源代码-哪位大神可以帮我讲解一下这个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:UsersshuqiDesktop新建文本文档.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

解决方案

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

解决方案二:
开头几句给你翻译下,别的去请教你的英语老师:
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 单页和双页区分页眉页脚
。。。

解决方案三:
呵呵,你要是经常和代码打交道的话,英语一般般,这些属性基本上一看就知道个大概。

要是想逐一弄懂都是什么意思,可以安装下面步骤:

录制一段宏(专录页面设置部分),随便设置几项内容,结束宏后查看代码然后逐一对应看是什么意思,
有不懂的属性直接在vba窗口内打开对象浏览器然后搜索相关的属性,看看是如何使用的。
比如:

Sub Macro1()'' Macro1 Macro' 宏在 2015/1/9 由 MicroDDD 录制'    With ActiveDocument.Styles(wdStyleNormal).Font        If .NameFarEast = .NameAscii Then            .NameAscii = """"        End If        .NameFarEast = """"    End With    With ActiveDocument.PageSetup        .LineNumbering.Active = False        .Orientation = wdOrientLandscape        .TopMargin = CentimetersToPoints(3.17)        .BottomMargin = CentimetersToPoints(3.17)        .LeftMargin = CentimetersToPoints(2.54)        .RightMargin = CentimetersToPoints(2.54)        .Gutter = CentimetersToPoints(0)        .HeaderDistance = CentimetersToPoints(1.5)        .FooterDistance = CentimetersToPoints(1.75)        .PageWidth = CentimetersToPoints(29.7)        .PageHeight = CentimetersToPoints(21)        .FirstPageTray = wdPrinterAutomaticSheetFeed        .OtherPagesTray = wdPrinterAutomaticSheetFeed        .SectionStart = wdSectionNewPage        .OddAndEvenPagesHeaderFooter = False        .DifferentFirstPageHeaderFooter = False        .VerticalAlignment = wdAlignVerticalTop        .SuppressEndnotes = False        .MirrorMargins = False        .TwoPagesOnOne = False        .BookFoldPrinting = False        .BookFoldRevPrinting = False        .BookFoldPrintingSheets = 1        .GutterPos = wdGutterPosLeft        .LayoutMode = wdLayoutModeLineGrid    End WithEnd Sub

解决方案四:
呵呵,我的word技巧还有不少是我的英语老师教我的。

时间: 2024-07-31 12:07:51

源代码-哪位大神可以帮我讲解一下这个vb程序啊 ,感激不尽的相关文章

mysql-eclipseEE连接My SQL出现问题,哪位大神可以帮我看看*^__^*,非常感谢

问题描述 eclipseEE连接My SQL出现问题,哪位大神可以帮我看看*^__^*,非常感谢 我是想连接MySQL和server SQL数据库,一般来说是在eclipse,通过buil path,然后add external jar配置就可以了,但是我尝试了这样去配置,结果还是不行.然后呢,我有特意去配置了我的环境变量,就是通过"我的电脑--系统--设置环境变量"建立一个classpath变量,然后把驱动的路径作为其变量,但是结果还是不行.最后,我认为可能是版本的驱动问题,然后我就

c++-初学C++编程,有没有哪位大神愿意帮我看一下?

问题描述 初学C++编程,有没有哪位大神愿意帮我看一下? 一道双向链表的题目,我按刘汝佳书上的写的,基本上和刘汝佳写的程序没什么区别,不一样的地方我认为我这样写也没错,但是不知道为什么评测时标程就AC,我写的就WA,有没有前辈愿意帮我看一下哪里出了问题?不胜感激! 标程 // UVa12657 Boxes in a Line // Rujia Liu #include<cstdio> #include<algorithm> using namespace std; const in

哪位大神可以帮我写下在Oracle数据库中查询出来的数据在jsp页面中进行分页显示,我已经能显示了,但是没有分页,直接改我的代码,我初学,没做过分页

问题描述 这是JSP页面代码:<%@pagelanguage="java"contentType="text/html;charset=gbk"pageEncoding="GBk"%><%@pageimport="com.etc.sky.entity.Record"%><%@pageimport="java.util.*"%><!DOCTYPEHTMLPUBLIC&

opencv-各位大神 求帮我看看 一运行 就中断

问题描述 各位大神 求帮我看看 一运行 就中断 // demo19.cpp : 定义控制台应用程序的入口点.// #include ""stdafx.h""#include#include#include #include int _tmain(int argc _TCHAR* argv[]){ IplImage* frame; IplImage* frame2; IplImage* frame3; frame=cvLoadImage(""E:\

关于 tpinit 的问题,哪位大神可以帮个忙~

问题描述 我自己写的一个java通信系统,将tuxedo客户端逻辑以JNI的形式作为主系统的一个通信模块,tuxedo客户端的编程方式采取标准的流程,在tpcall之前做了,环境变量的初始化后开始调用tpinit(),成功之后给sendbuf和recvbuff分配初始化空间,tpcall结束之后,取得recvbuff中的返回,然后断开连接,总之就是采取短连接和同步tpcall的方式.下面是我遇到的窘境:在实际企业级应用中,由于我的通信系统会接受前台发送过来给不同第三方tuxedo服务的报文信息,

ava cript-哪位大神帮我看一下里面那个值是怎么算出来最好能举例说明下

问题描述 哪位大神帮我看一下里面那个值是怎么算出来最好能举例说明下 function showLoginPop(){ $("#popupLogin").show(); } // === Begin Date.js var CalendarData=new Array(100); var madd=new Array(12); var tgString="甲乙丙丁戊己庚辛壬癸"; var dzString="子丑寅卯辰巳午未申酉戌亥"; var n

哪位大神帮我注释这段代码,最好详细一点(AT89s**与霍尔元件测速报警应用)。有附电路的原理图

问题描述 哪位大神帮我注释这段代码,最好详细一点(AT89s**与霍尔元件测速报警应用).有附电路的原理图 5C #includeunsigned char code table[12]={0xc00xf90xa40xb00x990x920x820xf80x800x900xff0xBF};unsigned char code table2[12]={0x400x790x240x300x190x120x020x780x000x100xff}; sbit CS3020=P1^0;sbit SET=P

把ckeditor上传完图片后宽高固定成100%,在哪里修改,哪位大神帮帮忙?

问题描述 把ckeditor上传完图片后宽高固定成100%,在哪里修改,哪位大神帮帮忙? 解决方案 修改CKEditorpluginsimagedialogsimage.js这个文件,找到下面2句,替换为下面的 C.setValueOf('info''txtWidth'D.$.width)C.setValueOf('info''txtHeight'D.$.height)=======>C.setValueOf('info''txtWidth''100%')C.setValueOf('info''

寻帮助-如何改红米手机锁屏音效,有哪位大神帮我一下,我自己手机音效听腻了

问题描述 如何改红米手机锁屏音效,有哪位大神帮我一下,我自己手机音效听腻了 如何改红米手机锁屏音效,有哪位大神帮我一下,我自己手机音效听腻了 解决方案 我的红米1S锁屏没有声音啊