首页 > 其他专区 > Access >

Access 如何利用Word对一段文字进行分词

Access 2021-09-18 09:08:41

一、问题描述:

现在有一串字符串内容,想自动识别出词语,这个该怎么来实现?

二、解决方法:

可以利用word分词的功能来实现,代码如下:

Dim sentence As String

Dim words As String

Dim WordApp As Object

If IsNull(Me.Text74) Then

MsgBox "请输入内容。", vbExclamation

Me.Text74.SetFocus

Exit Sub

End If

sentence = Me.Text74

words = ""

Set WordApp = CreateObject("Word.Application")

WordApp.Documents.Add

WordApp.Selection.TypeText Text:=sentence

WordApp.Selection.HomeKey

Do

WordApp.Selection.MoveRight Unit:=2, Count:=1, Extend:=1

If WordApp.Selection.Text = vbCr Then Exit Do

words = words & WordApp.Selection.Text & ";"

WordApp.Selection.MoveRight Unit:=1, Count:=1

Loop

WordApp.Quit SaveChanges:=0

Set WordApp = Nothing

Me.Text76 = words

End

三、演 示:

利用Word对一段文字进行分词

演示


标签: Access如何利用Word一段文字进行分词

office教程网 Copyright © 2016-2020 https://www.office9.cn. Some Rights Reserved.