老师们
做了一个文字翻译跟文档翻译的应用。
是调用百度翻译的API来进行翻译的。
关于文档翻译,目前已经做好了Excel的翻译功能。但是在Word的翻译上一直出问题。
各位老师能否帮忙看下 。
我使用过for each 文档的所有段落。然后每个段落拿去API上翻译回来替换上去。但是他翻译回来的内容会全部合并到一个段落去了。
如果有空白的段落还会报错。
If path.Contains(".doc") Then
Dim app As New MSWord.Application
Try
Dim doc = app.Documents.Open(path)
Dim SenCount As Integer = Doc.Sentences.Count '取得所选内容的句子数
Dim K As Integer
For k = 1 To sencount
Dim strs As String = doc.paragraphs(k).range.text
If strs.Length > 1 Then
doc.paragraphs(k).range.text = Functions.Execute("translation_language",strs,s,r)
End If
strs = ""
Next
rpath = "c:\reports\test.doc"
Doc.Save(rpath)
Doc.Close
app.Quit
msgbox(ex.message)
Finally
End Try
End If
具体了可以查看附件