Const wdWord9TableBehavior = 1
Const wdAutoFitFixed = 0
Sub Add_Doc_Zadvizhek()
Dim objWord As Object, objDocument As Object
Set objWord = CreateObject("Word.Application")
Set objDocument = objWord.Documents.Add
With objDocument.Tables.Add(Range:=objDocument.Range, _
NumRows:=1, NumColumns:=4, DefaultTableBehavior:= _
wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
'.Style = "Сетка"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
objWord.Visible = True 'Для наглядности
End Sub
Как работать с объектом selection ячейки таблицы word из приложения Excel в ВБА
Sub Add_Doc_Zadvizhek()
Dim oWord As Object
Dim oDocument As Object
Dim ApplWord As Object
Dim Mytime, myTimeSokr As String
Dim MyDate As String
Dim TimeDate As String
Dim NameWihtoutDate, SaveFileName As String
Dim Dlina_Mytime As Integer
Dim Putfile As String
Dim tableNew As Object
Dim docActive As Object
Dim i As Integer
Dim myRange As Object
Set oWord = CreateObject("Word.Application")
Set oDocument = oWord.Documents.Add
Set docActive = oWord.ActiveDocument
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Сетка" Then
.Style = "Сетка"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
Selection.MoveDown Unit:=wdLine, Count:=2
selection.TypeParagraph
selection.TypeParagraph
Цитата: pashulka
Код:
Const wdWord9TableBehavior = 1
Const wdAutoFitFixed = 0
Sub Add_Doc_Zadvizhek()
Dim objWord As Object, objDocument As Object
Set objWord = CreateObject("Word.Application")
Set objDocument = objWord.Documents.Add
With objDocument.Tables.Add(Range:=objDocument.Range, _
NumRows:=1, NumColumns:=4, DefaultTableBehavior:= _
wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
objWord.Visible = True 'Для наглядности
End Sub
Const wdAutoFitFixed = 0
Sub Add_Doc_Zadvizhek()
Dim objWord As Object, objDocument As Object
Set objWord = CreateObject("Word.Application")
Set objDocument = objWord.Documents.Add
With objDocument.Tables.Add(Range:=objDocument.Range, _
NumRows:=1, NumColumns:=4, DefaultTableBehavior:= _
wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
objWord.Visible = True 'Для наглядности
End Sub
Спасибо