О компании Менеджмент Переводы Программирование Робототехника Все проекты Контакты
Админка
пожалуйста подождите

If CurPar.Range.Tables.Count > 0 Then

' creating the temporary document for tables convertion
Dim TablesDoc As Document
Set TablesDoc = Documents.Add
CurPar.Range.Tables(1).Range.Cut
TablesDoc.Content.Paste

' formatting tables
While TablesDoc.Tables.Count > 0

' searching for the first simple table (with no tables inside)
Dim TablePar As Paragraph
Dim TableParIndex As Integer
For TableParIndex = TablesDoc.Paragraphs.Count To 1 Step -1
Set TablePar = TablesDoc.Paragraphs(TableParIndex)

' first finding the paragraph, that has a table inside
If TablePar.Range.Tables.Count > 0 Then

'taking the first one and checking, if it is a simple one
Dim IsSimpleTable As Boolean
IsSimpleTable = True
Dim InsideTablePar As Paragraph
For Each InsideTablePar In TablePar.Range.Tables(1).Range.Paragraphs
If InsideTablePar.Range.Tables.Count > 0 Then
If InsideTablePar.Range.Tables(1).Range <> _
TablePar.Range.Tables(1).Range.Paragraphs(1).Range.Tables(1).Range Then
IsSimpleTable = False
End If
End If
Next

' converting the simple table, just found
If IsSimpleTable Then
Dim TempTable As Document
' moving to the next table
TableParIndex = TableParIndex - TablePar.Range.Tables(1).Range.Paragraphs.Count

' converting this one
Set TempTable = GenerateHTMLTable(TablePar.Range.Tables(1))
TempTable.Select
If Not StyleExists(TempTable, NoFormattingStyle) Then
TempTable.Styles.Add Name:=NoFormattingStyle
End If
Selection.Style = NoFormattingStyle
TablePar.Range.Tables(1).Range.Select
TablePar.Range.Tables(1).Delete
Selection.Collapse direction:=wdCollapseStart
Selection.FormattedText = TempTable.Range

' freing unused document
TempTable.Close (False)
End If

End If

Next
Wend
' outputting
Output.Content.InsertAfter Text:=TablesDoc.Range.Text
' freeing unused document
TablesDoc.Close (False)
End If
 
 
 
Языки
Темы
Copyright © 1999 — 2023
Зетка Интерактив