MS Word 可扩展性:VBA 宏与 .Net VSTO?
我的一位客户要求我们开发一个“VBA 宏”。然而,在 2010 年代,仍然使用这种过时的语言对我来说似乎很奇怪,我正在考虑尝试说服客户使用 VSTO dev。然而,由于我对这两个世界都是新手,我需要帮助来填写赞成/反对页面,以便能够争论这一点。
当然,没有实际需求就不可能有答案,让我试着恢复一下:
目标:Word 2003/2007(但我怀疑 2010 年为未知要求)编辑 2010 年要求已确认
外部发布系统需要 .doc 文件作为输入。 .doc 文件必须应用一些特定样式:“自定义标头 1”、“自定义标头 2”等。
用户可以使用 Word 构建文档,使用两种可能的方式:
- 使用计算机上部署的 .dot 文件启动新文档
- 转换任何现有文档以匹配目标模板
用户可以“简单地”“应用”样式(简单的 UI):上下文菜单、样式菜单、自定义操作窗格等。
现在,我明白了以下优点/缺点:
VBA
- 优点:
- ?
- 快速而肮脏的开发(句子的快速部分)
- 客户已经有一些正在生产的宏
- 缺点:
- 很难找到熟练的开发人员
- 快速而肮脏的开发(句子的肮脏部分)
- 优点:
VSTO
- 优点:
- .Net 语言的优点(编译、类型化、严谨、类库等)
- 安全模型更加灵活和强大(信任由可信机构签名的代码)
- 可以桥接到 WPF 窗格
- 您使用 Visual Studio 工作并可以使用其全套功能:重构、源代码控制等。
- 缺点:
- 需要安装 .Net 框架(今天可能不是问题)和 VSTO 运行时
- 部署更困难
- 开始时工作量稍多(但长期来看会减少)
- 优点:
One of my customers asked us to develop a "VBA macro". However, in the 2010s, it seems weird to me to still use such outdated language, and I'm thinking about trying to convince the customer to use VSTO dev instead. However, as I'm new to both worlds, I need help to fill a pro/cons page to be able to argue this.
Of course, the answer can't come without the actual requirement, let me try to resume:
Target : Word 2003/2007 (but I'm suspecting 2010 as a not yet known requirement) edit 2010 requirement confirmed
An external publishing system requires .doc file as input. The .doc file must have some specific styles applied : "Custom Header 1", "Custom header 2", etc.
The user can build documents, using Word, using two possible ways:
- Start the new document using a .dot file deployed on the computer
- Transform any existing document to match the target template
Users can "apply" the styles "simply" (simple UI): context menu, styles menu, custom action pane, etc.
By now, I see the following pro/cons:
VBA
- Pros:
- ?
- quick and dirty development (quick part of the sentence)
- The customer has already some in production macro
- Cons:
- hard to find skilled developer
- quick and dirty development (dirty part of the sentence)
- Pros:
VSTO
- Pros:
- benefits of the .Net language (compiled, typed, rigorous, class library, etc.)
- security model more flexible and powerful (trusting code signed with a trusted authority)
- bridge to WPF panes possible
- You work in Visual Studio and have access to its full set of features: refactoring, source control, etc.
- Cons:
- requires installation of the .Net framework (probably not an issue today) and VSTO runtime
- harder to deploy
- slightly more work at the start (but less in long term)
- Pros:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我对 .NET 不太熟悉,但以下是我对 VBA 的拙见:
VBA
很难找到熟练的开发人员需要安装 .Net 框架(今天可能不是问题)我不这么认为(也许是 VSTO 的缺点?)我想说,如果你只想有一些代码或加载项来合并一些syles, 你可以轻松地做到这一点VBA 并且它不会被弄脏(除非你真的想要它)。
I am not familiar enough to .NET but here is my humble opinion about VBA:
VBA
hard to find skilled developerrequires to have the .Net framework installed (probably not an issue today)I don't think so (maybe a CONS of VSTO?)I would say that if you only want to have some code or add-in to merge some syles, you could easily do it with VBA and it won't be dirty (unless you really want it to).
随着项目的完成,我正在回答自己的问题。
我最终决定使用 VBA 宏来编写应用程序。以下是此选择的事后结论:
优点:
缺点:
备注:
作为经验丰富的 C# 开发人员,优点/缺点可能有点片面。
I'm answering myself to the question, as the project is finished.
I finally decided to write the application using a VBA macro. Here is the post-mortem conclusion of this choice :
Pros:
Cons:
Remark:
As an experienced C# developer, the pros/cons may be partial a bit.
我是一名重度 Excel VBA 开发人员。
VBA专业版:
我从 VBA 切换到 VSTO 的主要障碍之一 - 相信我,我喜欢 C# 编码 - 是没有我的用户群已经习惯的即时调试。我经常直接跳到用户 PC 上发生的 VBA 问题,但对于 VSTO,这是不可能的。 (除非有人可以纠正我。)
如果您的用户没有这样的期望,那么您可能可以轻松地生活在没有这样的期望的情况下。
VBA 缺点:
VBA 是一种易于使用,因此也很容易搞乱的语言。它不强制执行“干净编码”原则,这意味着虽然优秀的程序员可以使用它们编写出色的应用程序,但由于 VBA 的入门门槛较低,它可能会与黑客工作和庞大的有机代码联系在一起。由于这个原因,VBA 开发人员通常被认为是较低级别的开发人员,而实际上却无法区分那些明智地使用它的人和那些不明智地使用它的人。
我怀疑是否有人会选择 VBA 作为他们的职业语言,这只是发生在他们身上。除了很难找到熟练的开发人员之外,过多的 VBA 工作可能会拒绝潜在的员工,因为他们不想卷入“另一个不受管理的 VBA 蔓延的泥潭”。有些人用 VBA 来表达你对技术有多“认真”。
(我倾向于以同样的眼光看待 Perl;非常适合短脚本,但是当习惯使用脚本编写的人开始使用更大的工作时 - 你往往会得到一些有点笨拙的东西。)
I am a heavy Excel VBA developer.
VBA pro:
One of the major hurdles for me switching over to VSTO from VBA - and believe me, I love C# coding - is that there's no debug-on-the-fly which my userbase has got used to. I often jump straight into a VBA problem on the user's PC as it is happening, but with VSTO, that's not possible. (Unless someone can correct me.)
If your users have no such expectations this might be something you can easily live without.
VBA con:
VBA is one of the those languages that are easy to play with and thus easy to make a mess with. It doesn't enforce "clean coding" principles which means while decent programmers can make great applications with them, VBA can become associated with hackjobs and sprawling, organic code due to its low bar of entry. VBA developers are often considered a lower class of developer for this reason, when really there is a failure to distinguish between those that use it wisely and those that don't.
I doubt anyone chooses VBA as their career language of choice, it just sort of happens to them. Aside from being hard to find skilled developers, too much VBA work might turn away potential hires as they don't want to be associated with the "quagmire of another unmanaged VBA sprawl". Some people take use of VBA as a statement about how "serious" you are about technology.
(I tend to see Perl in the same light; great for short scripts but when someone used to using for scripting starts to use for a larger piece of work - you tend to get something that's a bit unwieldy.)
在这篇文章中,我尝试总结类似的问题,在 Excel 上下文中。同样的论点适用于所有 Office 应用程序,包括 Word。
In this article I tried to summarize similar questions, in the context of Excel. Same arguments apply for all of the Office applications including word.
根据我的观察:
维斯托:
缺点:如果我们为word 2007开发了Addins功能区控件,则只能使用word 2007进行部署,而不能使用word 2010或word 2013进行部署。
这是我为 word 和 excel 的所有版本(如 2007、2010 和 2013)开发插件的主要缺点。如果有错,请纠正我,或者建议我如何为所有 Office 版本开发单个插件。
According to my observations :
VSTO :
CONS : that if we have developed Addins ribbons control for word 2007, we can only deploy with word 2007, but we can not deploy with word 2010 or word 2013.
This is major drawback for me to develop Addins for word and excel for all its versions like 2007, 2010 and 2013. plz correct me if am wrong or suggest me how could I develop Single Addins for all office version.