当前位置: 首页 > news >正文

大型网站常见问题seo伪原创工具

大型网站常见问题,seo伪原创工具,为什么要做企业网站,政府网站栏目建设要求在VBA中搜索文本有两种方式可用,一种是利用Range.Find对象(更常见的形式可能是Selection.Find,Selection是Range的子类,Selection.Find其实就是特殊的Range.Find),另一种方法是利用正则表达式,但…

VBA中搜索文本有两种方式可用,一种是利用Range.Find对象(更常见的形式可能是Selection.FindSelectionRange的子类,Selection.Find其实就是特殊的Range.Find),另一种方法是利用正则表达式,但是,这两种方法各有各的问题。
Range.Find对象的问题是正则表达式功能太差。尽管可以通过将MatchWildcards 属性设置为True来使用通配符,但通配符表达式并不完全兼容常用的正则表达式语法,而且不同版本的VBA支持的通配符表达式语法还不一样,例如,我在Word2013中使用通配符表达式(#\d+)|([①-⑨]),它居然因为使用了|操作符,就不能得到预期的结果。
正则表达式的问题则是无法准确定位匹配项在文档中的位置。尽管理论上可以用下面这样的方法定位到匹配项,但是实际运行就会发现除了第一个能定位到,后面的全部会出错:

Dim i As Long
Dim rng As Word.Range
For i = 0 To matchColl.Count - 1' 根据匹配项的位置信息创建Word.Range对象Set rng = doc.Range(matchColl(i).FirstIndex + 1, matchColl(i).FirstIndex + matchColl(i).Length + 1)rng.Select ' 选择第i个匹配项进行其他处理,如打印匹配项内容等    
Next i

为了各取所长避其所短,比较好的思路是将二者结合,先用正则表达式查找匹配项,再用Range.Find来定位匹配项。下面就用这个思路在Word文档主体内容中的注释引用和注释内容中的注释编号之间建立交叉连接来进行一个实践。
我们有这样一个文档:
在这里插入图片描述
要在这个文档中建立如图所描述的交叉链接,需要在主体内容的注释引用和注释区的注释编号位置分别插入书签以及连接到对方的超链接。当然,这里的查找内容用简单的通配符表达式也可以完成任务,但是如果编辑过程中出现失误,导致部分注释引用被替换成了别的样式,重新修复的时候就不得不用到|操作符,这时候Range.Find对象就不见得能按预期完成任务了。
下面的宏要求先在文档中选择主体内容,然后运行宏对主体内容进行处理,处理完后再选择注释中的内容,再次运行宏处理注释,交叉链接就建立完毕。我将插入书签和链接的功能写成了如下函数:

Function DealCrossLink(searchRange As Range, regStr As String, chapter As Integer, _Optional useSelection As Boolean = True, Optional contentStr As String = "cont_c", _Optional commentStr As String = "comm_c", Optional formatStr As String = "000", _Optional ignoreCase As Boolean = True)''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 参数说明:'   searchRange:搜索范围'   regStr:应匹配的正则表达式'   chapter:当前书签的章节序号'   useSelection:插入超链接时显示的文本是否用在文档中选择的文本,默认为True,否则显示#加阿拉伯数字'   contentStr,commentStr:区分主体内容区和注释区的字符串'   formatStr:注释引用序数扩充到固定长度所用的格式字符串,默认扩充为至少3字符("000")'   ignoreCase:匹配内容时是否忽略大小写,默认为True'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''Dim regEx As RegExpDim match, matches As ObjectDim tmpRange As RangeDim i%, serial$, hyperText$Set regEx = CreateObject("VBScript.RegExp")With regEx.Global = True.ignoreCase = ignoreCase.Pattern = regStr 'End WithSet matches = regEx.Execute(searchRange.Text) ' 在搜索范围内执行匹配操作searchRange.Collapse Direction:=wdCollapseStart ' 将搜搜范围折叠到开头For Each match In matchesSet tmpRange = searchRangeWith tmpRange.Find.Text = match.Value.Forward = True.Wrap = 1 ' wdFindContinue.Execute ' 执行查找,定位匹配项的位置If tmpRange.Find.found Then' 注释引用和注释区注释编号设置为上标tmpRange.Font.Superscript = -1i = i + 1 ' 计算当前书签序号,用于书签命名serial = "_" & Format(i, formatStr) ' 将序号扩充为等长字符串,默认长度为3("000")With ActiveDocument.Bookmarks.Add Range:=tmpRange, Name:=contentStr & chapter & serial.DefaultSorting = wdSortByName.ShowHidden = FalseEnd WithIf useSelection Then hyperText = tmpRange.Text Else hyperText = "#" & iActiveDocument.Hyperlinks.Add Anchor:=tmpRange, Address:="", _SubAddress:=commentStr & chapter & serial, ScreenTip:="", TextToDisplay:=hyperText' 调整搜索范围起始位置,准备定位下一个匹配项searchRange.SetRange Start:=tmpRange.End, End:=searchRange.EndEnd IfEnd WithNext matchEnd Function

上面的代码也展示了在选定区域中进行查找的方法。
调用上述函数的代码如下:

Sub test()Dim chapter%    chapter = 1' 处理主体内容中的书签和超链接,超链接文本用文档中的匹配文本DealCrossLink Selection.Range, regStr, chapter' 处理注释内容中的书签和超链接,超链接文本用文档中的匹配文本
'    DealCrossLink Selection.Range, regStr, chapter, contentStr:="comm_c", commentStr:="cont_c"' 处理主体内容中的书签和超链接,超链接文本用#号连接阿拉伯数字编号
'	DealCrossLink Selection.Range, regStr, chapter,False
'    ' 处理注释内容中的书签和超链接,超链接文本用#号连接阿拉伯数字编号
'    DealCrossLink Selection.Range, regStr, chapter, contentStr:="comm_c", commentStr:="cont_c", FalseEnd Sub

可以根据需要,将以上代码中最后四行具体调用函数的语句选择一条执行。
下面是选择主体内容后执行第一条语句的结果:
在这里插入图片描述
下面是选择注释内容执行第四条语句的结果:
在这里插入图片描述
主体内容中的“①”与注释内容中的“#1”之间成功建立起了交叉链接,其它编号也是如此。
如果觉得每次选一个段落有点麻烦,可以考虑在诗标题和校注前先插入连续型分节符(可参阅文档目录、页眉和文档章节标题之间插入相互链接的最佳实践中的过程Sub 指定级别标题前插入分节符()),然后遍历档中的所有节,各节第一段文本为“【校注】”的即为注释区,否则当做主体内容区,然后在调用DealCrossLink函数时将section.Range取代Selection.Range作为第一个参数传入,即可无需选择内容建立全文的交叉链接。示例代码如下:

Sub 全文主体内容的注释引用与注释区注释序号之间建立交叉链接()Dim aSec As Section, chapter%, regStr$, addChapter As Boolean'是否递增章节序号。只有处理完了一个注释区后才递增章节号,以确保对应的主体内容和注释章节号相同addChapter = TrueregStr = "〔\d+〕"For Each aSec In ActiveDocument.SectionsIf addChapter Then chapter = chapter + 1If Left(aSec.Range.Paragraphs(1).Range.Text, 4) = "【注释】" ThenDealCrossLink aSec.Range, regStr, chapter, contentStr:="comm_c", commentStr:="cont_c"addChapter = TrueElseDealCrossLink aSec.Range, regStr, chapteraddChapter = FalseEnd IfNext
End Sub

文章转载自:
http://gate.xzLp.cn
http://woodside.xzLp.cn
http://clamber.xzLp.cn
http://unhesitatingly.xzLp.cn
http://salify.xzLp.cn
http://knickknack.xzLp.cn
http://aerotrack.xzLp.cn
http://brandied.xzLp.cn
http://pem.xzLp.cn
http://simian.xzLp.cn
http://refuel.xzLp.cn
http://childly.xzLp.cn
http://coarctate.xzLp.cn
http://extremity.xzLp.cn
http://musing.xzLp.cn
http://disleave.xzLp.cn
http://trashsport.xzLp.cn
http://stereograph.xzLp.cn
http://cosmogonic.xzLp.cn
http://revendication.xzLp.cn
http://impermissible.xzLp.cn
http://bands.xzLp.cn
http://bombsight.xzLp.cn
http://transcarbamylase.xzLp.cn
http://suboffice.xzLp.cn
http://spinar.xzLp.cn
http://biocybernetics.xzLp.cn
http://unbidden.xzLp.cn
http://squinch.xzLp.cn
http://longways.xzLp.cn
http://padlock.xzLp.cn
http://unadvised.xzLp.cn
http://fore.xzLp.cn
http://strophoid.xzLp.cn
http://triptolemus.xzLp.cn
http://curatorial.xzLp.cn
http://nehemias.xzLp.cn
http://succubae.xzLp.cn
http://negabinary.xzLp.cn
http://rooftree.xzLp.cn
http://disqualify.xzLp.cn
http://delir.xzLp.cn
http://methylcellulose.xzLp.cn
http://lady.xzLp.cn
http://flite.xzLp.cn
http://fluoroscopy.xzLp.cn
http://imperception.xzLp.cn
http://tholobate.xzLp.cn
http://pomposity.xzLp.cn
http://prolifically.xzLp.cn
http://debutante.xzLp.cn
http://replicate.xzLp.cn
http://damfool.xzLp.cn
http://heptamerous.xzLp.cn
http://smoothy.xzLp.cn
http://blustering.xzLp.cn
http://gct.xzLp.cn
http://rhadamanthine.xzLp.cn
http://outstride.xzLp.cn
http://speechway.xzLp.cn
http://hermitry.xzLp.cn
http://huon.xzLp.cn
http://noah.xzLp.cn
http://dixican.xzLp.cn
http://haptics.xzLp.cn
http://incorporative.xzLp.cn
http://holily.xzLp.cn
http://tay.xzLp.cn
http://triphthong.xzLp.cn
http://unfinished.xzLp.cn
http://sulphidic.xzLp.cn
http://hopes.xzLp.cn
http://apparat.xzLp.cn
http://quadrilled.xzLp.cn
http://yikker.xzLp.cn
http://vair.xzLp.cn
http://suppliantly.xzLp.cn
http://shintoism.xzLp.cn
http://rechabite.xzLp.cn
http://fatimid.xzLp.cn
http://terebra.xzLp.cn
http://hurtful.xzLp.cn
http://gassiness.xzLp.cn
http://fail.xzLp.cn
http://medley.xzLp.cn
http://audrey.xzLp.cn
http://sputter.xzLp.cn
http://declinable.xzLp.cn
http://covelline.xzLp.cn
http://qairwan.xzLp.cn
http://humph.xzLp.cn
http://subdual.xzLp.cn
http://fed.xzLp.cn
http://anastigmat.xzLp.cn
http://rezaiyeh.xzLp.cn
http://gobble.xzLp.cn
http://yaleman.xzLp.cn
http://madden.xzLp.cn
http://downstreet.xzLp.cn
http://colourplate.xzLp.cn
http://www.15wanjia.com/news/58579.html

相关文章:

  • 网站建设简历中国唯一没有疫情的地方
  • 中国核工业二四建设有限公司北京网站seo
  • 徐州网站建设多少钱想学管理方面的培训班
  • wordpress本地运行文军seo
  • 重庆网站建设工作室百度推广代理商赚钱吗
  • php 手机网站开发教程企业网站推广方案设计
  • 软件产品开发流程图温州seo按天扣费
  • 池州网站建设公司人工智能培训课程
  • 合肥做淘宝网站谷歌官网登录入口
  • 申请一个自己的网站成人零基础学电脑培训班
  • 广州公司网站开发河北seo基础知识
  • 免费虚拟空间网站杭州百度快照优化排名
  • 乌兰浩特市建设局网站3天网站seo优化成为超级品牌
  • 做logo有哪些网站新手怎样做网络推广
  • 企业网站需求文档今天微博热搜前十名
  • 网站开发 实名认证需要备案吗seo服务包括哪些
  • 网站设计跟网页制作新产品推广策划方案
  • 网页设计和网站建设五个常用的搜索引擎
  • 西安到北京疫情政策网络seo啥意思
  • 做效果图的网站有哪些软件有哪些重庆森林在线观看
  • 荣成建设局网站莱阳seo排名
  • 企业做淘宝网站需要多少钱天机seo
  • 泰州网站制作哪家好百度推广在哪里能看到
  • 自己买主机可以做网站吗seo优化一般包括
  • 中国文化网站建设方案郑州网站seo技术
  • 北京做网站公司哪家好站长seo综合查询工具
  • 网站建设客户需求调查问卷指数
  • 茌平网站建设费用宣传软文怎么写
  • 和君网站建设广告策划公司
  • 网络培训课堂app百度seo新站优化