[英]Combine wdSeparateByTabs and wdSeparateByDefaultListSeparator= "|" while executing ConvertTblsToText()
I am trying to get a way to combine wdSeparateByTabs and wdSeparateByDefaultListSeparator= "|"我试图找到一种方法来结合 wdSeparateByTabs 和 wdSeparateByDefaultListSeparator= "|" while converting a word document which has tables to a text file.同时将具有表格的word文档转换为文本文件。 Because I am still learning VBA, Could anyone help me?因为我还在学习 VBA,有人可以帮帮我吗?
Here are the codes which was used:以下是使用的代码:
Sub ConvertTblsToText()
‘Convert all tables to text.
Dim tbl As table
If ActiveDocument.tables.Count = 0 Then
MsgBox “There are no tables in this document.”, vbOKOnly, “Error”
Exit Sub
End If
For Each tbl In ActiveDocument.tables
‘wdSeparateByCommas, wdSeparateByDefaultListSeparator,
‘wdSeparateByParagraphs, wdSeparateByTabs
tbl.ConvertToText Separator:=wdSeparateByTabs
Next
End Sub
and to include "|"并包括“|” This code:这段代码:
Sub text_zu_tabelle()
Dim meinetabelle As Table
Application.DefaultTableSeparator = "*"
Set meinetabelle = Selection.ConvertToTable(Separator:=wdSeparateByDefaultListSeparator)
End Sub
Thank you in advance.先感谢您。
It's not exactly clear what you're trying to achieve, but it seems all you need is:目前尚不清楚您要实现的目标,但您似乎只需要:
Sub ConvertTblsToText()
Application.ScreenUpdating = False
With ActiveDocument
If .Tables.Count = 0 Then
MsgBox "There are no tables in this document.", vbOKOnly, "Error"
Exit Sub
End If
Do While .Tables.Count > 0
.Tables(1).ConvertToText Separator:="|"
Loop
End With
Application.ScreenUpdating = True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.