如何漂亮地打印 VBA 代码? [英] How to Pretty print VBA code?

查看:21
本文介绍了如何漂亮地打印 VBA 代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 VBA 代码复制到 Word 文档中并保留 VBA 编辑器配色方案?

How do you copy VBA code into a Word document and retain the VBA editor color scheme?

推荐答案

您可以使用 Notepad++ 以三种方式实现这一点.请注意,Notepad++ 是记事本的更高级版本,它支持开箱即用"的不同代码文件的语法高亮显示 - 包括 Visual Basic!

You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - Visual Basic included!

下载&安装它,启动它,然后加载你的 VBA 代码.您应该会自动看到它的漂亮颜色(如果没有,因为文件扩展名不是 .vb,请转到 Language -> VB 或 Language -> V -> VB).

Download & install it, fire it up, and load up your VBA code. You should automatically see it beautifully coloured (if not, because the file extension is something other than .vb, go to Language -> VB or Language -> V -> VB).

如果您需要更改任何颜色,您可以轻松完成 - 只需转到设置"->样式器配置器".从该菜单中,您可以更改各种突出显示和字体选项,以满足您的需要 - 尽管默认设置通常足以满足大多数需求.

If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.

然后,转到插件-> NppExport.从那里,您可以考虑三个选项:

Then, go to Plugins -> NppExport. From there, you have three options you can consider:

  • 直接从记事本++打印
  • 将所有格式复制到剪贴板
  • 导出到 RTF
  • 导出为 HTML

第一个是不言自明的.第二个 - 将所有格式复制到剪贴板" - 将使用突出显示的语法复制整个文件到剪贴板.单击它后,然后打开 Microsoft Word 或您喜欢的其他文档编辑器,然后点击粘贴!您应该会看到精美的语法高亮代码.如果出现问题,那么您可以尝试其他选项之一(导出到 RTF/HTML),尽管我从来没有遇到过剪贴板方法的问题.

The first is self explanatory. The second one - "Copy all formats to clipboard" - will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word or your other favourite document editor, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.

这篇关于如何漂亮地打印 VBA 代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆