基本操作

1)用Notepad++直接编辑代码文件,注意文件后缀,比如.cpp是C++程序,.m是Matlab,linux文件是.sh,写对后缀表示的文件类型,才有对应的语法高亮效果。

2)选中需要的代码块(或者不选,默认对全文操作),使用“插件 -> NppExport”,具体见下图

3)直接粘贴到Word就行了。

更加智能与自动化

office套件提供了VBA,让用户可以写程序、宏来辅助完成办公操作。VBA使用最广泛的当属Excel了。Alt + F11可以进入VBA,然后点击“插入”-“模块”:

然后把下面的代码复制到“模块1”并保存。

Sub 设置代码表格()
' author: code4101
' 设置代码表格 宏
'
'
' 背景色为morning的配色方案,RGB为(229,229,229)
With Selection.Tables()
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor =
End With
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
.AutoFitBehavior (wdAutoFitContent) '自动调整大小
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With ' 段落无首行缩进,行间距为固定值12磅
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints()
.RightIndent = CentimetersToPoints()
.SpaceBefore =
.SpaceBeforeAuto = False
.SpaceAfter =
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceExactly
.LineSpacing =
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints()
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent =
.CharacterUnitRightIndent =
.CharacterUnitFirstLineIndent =
.LineUnitBefore =
.LineUnitAfter =
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
.AutoAdjustRightIndent = True
.DisableLineHeightGrid = False
.FarEastLineBreakControl = True
.WordWrap = True
.HangingPunctuation = True
.HalfWidthPunctuationOnTopOfLine = False
.AddSpaceBetweenFarEastAndAlpha = True
.AddSpaceBetweenFarEastAndDigit = True
.BaseLineAlignment = wdBaselineAlignAuto
End With
' 清除原有的段落底纹
Selection.ParagraphFormat.Shading.BackgroundPatternColor = wdColorAutomatic
End Sub Sub 输入连续数字()
' author: code4101
行数 = InputBox("请输入代码终止行数", "输入行数", "")
For i = To 行数 -
Selection.TypeText Text:=i
Selection.TypeParagraph
Next
Selection.TypeText Text:=行数
End Sub
这里的两个宏,一个是输入连续数字的宏,另一个是对代码表格进行一些处理的宏,选中那个一行两列的表格,跑跑宏就知道效果了。(这两个宏的配置会比较个性化,读者可以根据自己的喜好来开发。)
       代码的最终形式如下
 

参考:https://blog.csdn.net/code4101/article/details/41802715

 
 
 
 
 
 
 
 
 
 

最新文章

  1. windows 上vmare超卡的问题解决方案
  2. curl php 小记
  3. BZOJ1798——[Ahoi2009]Seq维护序列seq
  4. 【leetcode】Subsets (Medium) ☆
  5. Tomcat DEBUG模式下修改代码立刻生效!
  6. netlink机制
  7. rails中ActionController::InvalidAuthenticityToken解决办法
  8. Static Class (静态类)
  9. 认识Junit
  10. BZOJ 1083: [SCOI2005]繁忙的都市【Kruscal最小生成树裸题】
  11. DMO节点内部插入的常用方法与区别
  12. [ffmpeg] 音频样本
  13. python练习题-day2
  14. ZVAL——PHP源码分析
  15. 使用命令行打包 nuget 包
  16. Spring4 mvc+maven 框架搭建(3)
  17. 连接redis
  18. 创造101:如果软件测试工程师组团出道,怎样才能站C位?!
  19. CF1082D:Maximum Diameter Graph (简单构造)
  20. Sqlmap注入技巧收集整理

热门文章

  1. python异常处理与断言以及日志模块
  2. 常用判断重复记录的SQL语句
  3. RPM包的版本号比较
  4. 基于centOS7:新手篇→tomcat安装配置
  5. FCM算法的matlab程序
  6. 《Java大学教程》—第16章 二维数组
  7. ELK+Kafka 企业日志收集平台(一)
  8. ant.design React使用Echarts,实力踩坑
  9. 【转】CocoaPods的使用教程
  10. Linux:Day9(下) 程序包管理