Word中怎么设置代码高亮
1、首先完成当前所有内容,建议把代码放入单独的文本框中,方便处理,也有较好的视觉效果。
记得一定要拷贝一份副本!因为很可能因为代码量比较多,处理宏的时候卡死,只能强制退出WORD了。2、当前文档新定义一个样式,命名为"code",专门用来对代码进行格式化。
由于是代码,所以推荐中文使用黑体(注释等),而英文使用等宽字体(courier new)。步骤如图。
3、选中代码,单击样式库 ccode,将代码应用该样式4、新建宏,步骤如图5、将VBA代码(在下一步中)拷贝进去,保存后关闭 (有VBA或相关程序经验者可根据自己需要进行相关修改,如关键词和高亮颜色等)复制内容到剪贴板'script to high light code In document Private Function isKeyword(w) As Boolean Dim keys As New Collection With keys .Add "if": .Add "else": .Add "elseif": .Add "case": .Add "switch": .Add "break" .Add "for": .Add "continue": .Add "do": .Add "while": .Add "foreach": .Add "echo" .Add "define": .Add "array": .Add "NULL": .Add "function": .Add "include": .Add "return" .Add "global": .Add "as": .Add "die": .Add "header": .Add "this": .Add "empty" .Add "isset": .Add "mysql_fetch_assoc": .Add "class": .Add "style" .Add "name": .Add "value": .Add "type": .Add "width": .Add "_POST": .Add "_GET" End With isKeyword = isSpecial(w, keys) End Function Private Function isSpecial(ByVal w As String, ByRef col As Collection) As Boolean For Each i In col If w = i Then isSpecial = True Exit Function End If Next isspeical = False End Function Private Function isOperator(w) As Boolean Dim ops As New Collection With ops .Add "+": .Add "-": .Add "*": .Add "/": .Add "&": .Add "^": .Add ";" .Add "%": .Add "#": .Add "!": .Add ":": .Add ",": .Add "." .Add "||": .Add "&&": .Add "|": .Add "=": .Add "++": .Add "--" .Add "'": .Add """" End With isOperator = isSpecial(w, ops) End Function Private Function isType(ByVal w As String) As Boolean Dim types As New Collection With types .Add "SELECT": .Add "FROM": .Add "WHERE": .Add "INSERT": .Add "INTO": .Add "VALUES": .Add "ORDER" .Add "BY": .Add "LIMIT": .Add "ASC": .Add "DESC": .Add "UPDATE": .Add "DELETE": .Add "COUNT" .Add "html": .Add "head": .Add "title": .Add "body": .Add "p": .Add "h1": .Add " h2" .Add "h3": .Add "center": .Add "ul": .Add "ol": .Add "li": .Add "a" .Add "input": .Add "form": .Add "b" End With isType = isSpecial(w, types) End Function Sub SyntaxHighlight() Dim wordCount As Integer Dim d As Integer ' set the style of selection Selection.Style = "ccode" d = 0 wordCount = Selection.Words.Count Selection.StartOf wdWord While d < wordcount="" d="d" +="" selection.moveright(wdword,="" 1,="" wdextend)="" w="Selection.Text" if="" iskeyword(trim(w))="True" then="" selection.font.color="wdColorBlue" elseif="" istype(trim(w))="True" then="" selection.font.color="wdColorDarkRed" selection.font.bold="True" elseif="" isoperator(trim(w))="True" then="" selection.font.color="wdColorBrown" elseif="" trim(w)="//" then="" 'line="" comment="" selection.moveend="" wdline,="" 1="" commentwords="Selection.Words.Count" d="d" +="" commentwords="" selection.font.color="wdColorGreen" selection.movestart="" wdword,="" commentwords="" elseif="" trim(w)="/*" then="" 'block="" comment="" while="" selection.characters.last=""><> "/" Selection.MoveLeft wdCharacter, 1, wdExtend Selection.MoveEndUntil ("*") Selection.MoveRight wdCharacter, 2, wdExtend Wend commentWords = Selection.Words.Count d = d + commentWords Selection.Font.Color = wdColorGreen Selection.MoveStart wdWord, commentWords End If 'move the start of selection to next word Selection.MoveStart wdWord Wend ' prepare For set lIne number Selection.MoveLeft wdWord, wordCount, wdExtend SetLIneNumber End Sub Private Sub SetLIneNumber() Dim lines As Integer lines = Selection.Paragraphs.Count Selection.StartOf wdParagraph For l = 1 To lines lIneNum = l & " " If l < 10="" then="" linenum="lIneNum" &="" "="" "="" end="" if="" selection.text="lIneNum" selection.font.bold="False" selection.font.color="wdColorAutomatic" p="Selection.MoveDown(wdLine," 1,="" wdmove)="" selection.startof="" wdline="" next="" end="" sub="" 6、选定代码文本,然后执行highlight脚本:“视图”-“宏”-="">
注意事项:处理前一定要对原文章进行备份,以免前功尽弃。处理较长代码时需要一定。
如何在线打开word文档并高亮显示指定关键字
本文通过一个实用例子完整演示如何在线打开word文档并高亮显示指定的关键文字。
1. 项目目的目前,Office文件的在线处理越来越深入人心,越来越多的办公系统中的Word文档都采用了SOAOffice中间件来在线打开保存,同时也产生了一些更好、更高级的需求,本文所讨论的正是这样的一个需求:打开文档的时候,高亮显示指定的关键字。搜索结果高亮显示关键字。
2. 思路写一个查找函数,可以在查找结束的时候,高亮显示所有的关键字,如果要求打开文档的时候就高亮显示的话,可以在文档打开的事件中处理;如果要高亮显示多个不同的关键字的话,可以用这个函数进行多次的搜索。3. 关键函数function MarkKeyWord(value){var appSlt = document.getElementById("SOAOfficeCtrl").Document.Application.Selection;appSlt.HomeKey(6); // 设置文档中的光标到文件首。
appSlt.Find.ClearFormatting();appSlt.Find.Replacement.ClearFormatting();appSlt.Find.Text = value;while (appSlt.Find.Execute()){appSlt.Range.HighlightColorIndex = 7; // 高亮时的背景色}appSlt.HomeKey(6);}4. 示例程序架构这里使用ASP.NET示例,关键代码就是上面的那个函数,用什么开发语言都可以做这个效果,这个应用也不涉及到保存,为了简单,保存的代码也忽略掉了。Demo/|---- Highlight.aspx // 打开文档的页面|---- Highlight.aspx.csDoc/ //存放文档的目录|-- test.doc //测试文件,test.asp就是打开的这个文件5. 代码编写Highlight.aspx************************<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Highlight.aspx.cs" Inherits="Highlight" %>
word of wisdom是什么意思
word of wisdom
智慧的言语;感悟生活;智慧语
例句
1.As a word of wisdom to other girls who think life with a foreinger is a paradise, she writes
给其他想像和外国人生活是天堂的女孩一句智慧之语,她写到
2.The Wisdom of One Word
一句话的智慧
3.The word of God on high is the fountain of wisdom, and her ways are everlasting commandments.
智慧的泉源是天上天主的言语,她的道路是永久的诫命。
4.In a word, those basic notions of modern Western civilization ought to be regarded as the highlight of Judaic wisdom.
现代西方文明的基本理念,在相当程度上应当看作是犹太智慧的结晶。
5.A flow of word is no proof of wisdom.
口若悬河不表明有智慧。
Word中怎么设置代码高亮
1、首先完成当前所有内容,建议把代码放入单独的文本框中,方便处理,也有较好的视觉效果。
记得一定要拷贝一份副本!因为很可能因为代码量比较多,处理宏的时候卡死,只能强制退出WORD了。2、当前文档新定义一个样式,命名为"code",专门用来对代码进行格式化。
由于是代码,所以推荐中文使用黑体(注释等),而英文使用等宽字体(courier new)。步骤如图。
3、选中代码,单击样式库 ccode,将代码应用该样式4、新建宏,步骤如图5、将VBA代码(在下一步中)拷贝进去,保存后关闭 (有VBA或相关程序经验者可根据自己需要进行相关修改,如关键词和高亮颜色等) 复制内容到剪贴板'script to high light code In document Private Function isKeyword(w) As Boolean Dim keys As New Collection With keys .Add "if": .Add "else": .Add "elseif": .Add "case": .Add "switch": .Add "break" .Add "for": .Add "continue": .Add "do": .Add "while": .Add "foreach": .Add "echo" .Add "define": .Add "array": .Add "NULL": .Add "function": .Add "include": .Add "return" .Add "global": .Add "as": .Add "die": .Add "header": .Add "this": .Add "empty" .Add "isset": .Add "mysql_fetch_assoc": .Add "class": .Add "style" .Add "name": .Add "value": .Add "type": .Add "width": .Add "_POST": .Add "_GET" End With isKeyword = isSpecial(w, keys) End Function Private Function isSpecial(ByVal w As String, ByRef col As Collection) As Boolean For Each i In col If w = i Then isSpecial = True Exit Function End If Next isspeical = False End Function Private Function isOperator(w) As Boolean Dim ops As New Collection With ops .Add "+": .Add "-": .Add "*": .Add "/": .Add "&": .Add "^": .Add ";" .Add "%": .Add "#": .Add "!": .Add ":": .Add ",": .Add "." .Add "||": .Add "&&": .Add "|": .Add "=": .Add "++": .Add "--" .Add "'": .Add """" End With isOperator = isSpecial(w, ops) End Function Private Function isType(ByVal w As String) As Boolean Dim types As New Collection With types .Add "SELECT": .Add "FROM": .Add "WHERE": .Add "INSERT": .Add "INTO": .Add "VALUES": .Add "ORDER" .Add "BY": .Add "LIMIT": .Add "ASC": .Add "DESC": .Add "UPDATE": .Add "DELETE": .Add "COUNT" .Add "html": .Add "head": .Add "title": .Add "body": .Add "p": .Add "h1": .Add " h2" .Add "h3": .Add "center": .Add "ul": .Add "ol": .Add "li": .Add "a" .Add "input": .Add "form": .Add "b" End With isType = isSpecial(w, types) End Function Sub SyntaxHighlight() Dim wordCount As Integer Dim d As Integer ' set the style of selection Selection.Style = "ccode" d = 0 wordCount = Selection.Words.Count Selection.StartOf wdWord While d < wordcount="" d="d" +="" selection.moveright(wdword,="" 1,="" wdextend)="" w="Selection.Text" if="" iskeyword(trim(w))="True" then="" selection.font.color="wdColorBlue" elseif="" istype(trim(w))="True" then="" selection.font.color="wdColorDarkRed" selection.font.bold="True" elseif="" isoperator(trim(w))="True" then="" selection.font.color="wdColorBrown" elseif="" trim(w)="//" then="" 'line="" comment="" selection.moveend="" wdline,="" 1="" commentwords="Selection.Words.Count" d="d" +="" commentwords="" selection.font.color="wdColorGreen" selection.movestart="" wdword,="" commentwords="" elseif="" trim(w)="/*" then="" 'block="" comment="" while="" selection.characters.last=""><> "/" Selection.MoveLeft wdCharacter, 1, wdExtend Selection.MoveEndUntil ("*") Selection.MoveRight wdCharacter, 2, wdExtend Wend commentWords = Selection.Words.Count d = d + commentWords Selection.Font.Color = wdColorGreen Selection.MoveStart wdWord, commentWords End If 'move the start of selection to next word Selection.MoveStart wdWord Wend ' prepare For set lIne number Selection.MoveLeft wdWord, wordCount, wdExtend SetLIneNumber End Sub Private Sub SetLIneNumber() Dim lines As Integer lines = Selection.Paragraphs.Count Selection.StartOf wdParagraph For l = 1 To lines lIneNum = l & " " If l < 10="" then="" linenum="lIneNum" &="" "="" "="" end="" if="" selection.text="lIneNum" selection.font.bold="False" selection.font.color="wdColorAutomatic" p="Selection.MoveDown(wdLine," 1,="" wdmove)="" selection.startof="" wdline="" next="" end="" sub="" 6、选定代码文本,然后执行highlight脚本:“视图”-“宏”-="">
注意事项:处理前一定要对原文章进行备份,以免前功尽弃。处理较长代码时需要一定时间,请耐心等待。
转载请注明出处51数据库 » wordhighlight