这几天接到的任务是实现,将整个的word文档里面按照某个指定 的字符进行切分:

最后使用vba代码实现了打开word文档,并且按照相关的标示符将文档进行分开,最后拿到想要的文档,实现代码如下:

Sub change()
'
' 打开一个word文档,读取里面的内容
'
'定义一个路径
Dim StrPath As String
StrPath = "D:\test1.docx"

Set oApp = CreateObject("Word.Application")
oApp.Visible = False
Set oDoc = oApp.Documents.Open(StrPath) 'StrPath为文件路径
'获得最后一段的内容
Content = oDoc.Content.Text
Dim s As String
s = Split(Content, "=")(1) '从特定字符进行分割,获取到具体的json数据一分为2
oDoc.Close True
Set oApp = Nothing
 MsgBox s
 
End Sub

至此问题解决

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-08-03
猜你喜欢
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-12-09
相关资源
相似解决方案