OfficeVba/README.md

51 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# TSOfficeVba
## 介绍
该项目主要是以类`VBA`的方式完成对 office 文件的读写,使用方式与`VBA`大致相同,可参考[微软 VBA 文档][1]
如:打开一个 word 文件
vba打开
```vbs
Dim path As String
Dim doc As Document
set path = "./default.docx"
set doc = Documents.Open FileName:=path ' 打开一个文件
doc.Activate ' 可设置doc为ActiveDocument
Msgbox ActiveDocument.Paragraphs.Count ' 可用doc/ActiveDocument进行操作
```
tsl 打开:
```cpp
path := "./default.docx"
application := new TSDocxApplication(); // new一个Application对象
doc := application.Documents.Open(FileName: path) // 通过application打开文件
doc.Activate; // 激活
ActiveDocument := application.ActiveDocument; // 需要通过application属性赋值才能使用ActiveDocument
echo ActiveDocument.Paragraphs.Count; // 也可用doc进行操作
```
## 帮助文档
[帮助文档][3]涵盖了**TSOfficeVBA**对`VBA`的支持情况,以及相关的**FAQ**
也可生成你的帮助文档
```txt
tsl .\demo\TSVbaDocxHelp.tsl --path=C:\\xxx\\funcext
```
`TSVbaDocxHelp.tsl`帮助脚本文件克隆后在demo目录下
`--path=`: 部署的路径
## 部署
该项目基于[**TSOffice**][2],所以部署到`funcext`时需要检查**TSOffice**是否部署
[1]: https://learn.microsoft.com/en-us/office/vba/api/overview/library-reference
[2]: https://git.mytsl.cn/tinysoft/OfficePlugin
[3]: ./TSVbaDocxHelp.docx