Office如何通过VSTO进行WORD插件开发?

文章目录

0.引言

VSTO(Visual Studio Tools for Office )是VBA的替代,是一套用于创建自定义Office应用程序的Visual Studio工具包。VSTO可以用Visual Basic 或者Visual C#扩展Office应用程序(例如Word、Excel、PPT)。本文通过VSTO进行Word插件开发总结,并进行记录。

1.工具准备

(1)安装Visual Studio

在百度等浏览器搜索"Visual Studio2022"安装包,然后安装即可。

(2)安装VSTO

在Visual Studio Installer中选择"Office/SharePoint开发"工具集进行安装。

2.WORD外接程序创建和生成

(1)新建项目

(2)创建功能区

(3)添加功能按钮

(4)实现功能代码

双击button1按钮,编写代码:

csharp 复制代码
using System.Windows.Forms;
  
MessageBox.Show("Hello, WordAddIns.");

3.外接程序生成并使用

参考资料:

1\] 一路向前的小Q. [vsto与word基础介绍-新建第一个word加载项〔1〕](https://blog.csdn.net/weixin_44182128/article/details/119477412?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168930295816800192235004%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168930295816800192235004&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-10-119477412-null-null.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&spm=1018.2226.3001.4187); 2022-01-24 \[accessed 2023-07-14\]. \[2\] 十四贝勒. [使用C#开发Word VSTO外接程序示例](https://blog.csdn.net/thanks_hck/article/details/128455600?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168930295816800192235004%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168930295816800192235004&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-8-128455600-null-null.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&spm=1018.2226.3001.4187); 2023-01-04 \[accessed 2023-07-14\]. \[3\] usdoc文档预览. [Word排版插件,VSTO公文排版,Word论文排版](https://blog.csdn.net/Kiss_code/article/details/118668227?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168930295816800192235004%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168930295816800192235004&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-9-118668227-null-null.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&spm=1018.2226.3001.4187); 2022-11-15 \[accessed 2023-07-14\]. \[4\] ejinxian. [VSTO 实现word的多级列表功能](https://blog.csdn.net/ejinxian/article/details/115773518?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168930295816800192235004%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168930295816800192235004&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-20-115773518-null-null.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&spm=1018.2226.3001.4187); 2021-04-16 \[accessed 2023-07-14\]. \[5\] Azhangyuaner. [深入理解vsto,开发word插件的利器](https://blog.csdn.net/Azhangyuaner/article/details/84930806?ops_request_misc=&request_id=&biz_id=102&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-1-84930806.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&spm=1018.2226.3001.4187); 2018-12-09 \[accessed 2023-07-14\]. \[6\] Azhangyuaner. [接触vsto,开发word插件的利器](https://blog.csdn.net/Azhangyuaner/article/details/84930986?ops_request_misc=&request_id=&biz_id=102&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-84930986.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&spm=1018.2226.3001.4187); 2018-12-09 \[accessed 2023-07-14\]. \[7\] chain881228. [VSTO Word2003 添加菜单栏, 添加工具栏](https://blog.csdn.net/chain881228/article/details/77069075?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168930295816800192235004%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168930295816800192235004&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-22-77069075-null-null.142%5ev88%5einsert_down38v5,239%5ev2%5einsert_chatgpt&utm_term=Office%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87VSTO%E8%BF%9B%E8%A1%8CWORD%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91%EF%BC%9F&spm=1018.2226.3001.4187); 2017-08-10 \[accessed 2023-07-14\].

相关推荐
温轻舟8 小时前
Python自动办公工具06-设置Word文档中表格的格式
开发语言·python·word·自动化工具·温轻舟
温轻舟1 天前
Python自动办公工具05-Word表中相同内容的单元格自动合并
开发语言·python·word·自动化办公·温轻舟
亮子AI2 天前
如何做一个类似Word的编辑器?要有修改标记功能
编辑器·word
低调电报2 天前
在WPS可以显示图片,word中不能显示的原因及解决
经验分享·word·wps
shouchaobao2 天前
免费PDF工具:PDF转Word/Excel/图片+AI总结+合并拆分+OCR识别,多端无广告!
pdf·word·excel
lqz19934 天前
根据html导出excel和word
html·word·excel
缺点内向4 天前
C# 中 Word 文档目录的插入与删除指南
开发语言·c#·word·.net
诸神缄默不语5 天前
如何用Python处理文件:Word导出PDF & 如何用Python从Word中提取数据:以处理简历为例
python·pdf·word
初九之潜龙勿用5 天前
C# 操作Word模拟解析HTML标记输出带格式的文本
开发语言·c#·word·office
裤裤兔6 天前
利用VBA批处理word 文档,使用宏对docx文件内容进行批量替换
c#·word·.net··vba·office·宏操作