Hello
This is my First VBA word coding via excel.
Partly Successful because what happens Table OverWrites on the Paragrpah and marked in Red gave me error Object does not support this property
Thanks NimishK
This is my First VBA word coding via excel.
Partly Successful because what happens Table OverWrites on the Paragrpah and marked in Red gave me error Object does not support this property
Code:
Private Sub cmdWordformat_Click()
Dim objWord As Word.Application
Dim txtString As String, sh As Worksheet
Dim objDoc 'As Document
Dim objRange 'As Range
Dim objTable 'As Table
Dim intRows As Integer
Dim intCols As Integer
txtString = " The Brown fox” & vbcrlf & “quickly Jumped over” & vbcrlf & “the Lazydogs“
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objWord.ActiveDocument.Content.FormattedText.Text = txtString
Set objRange = objDoc.Range
intRows = 2: intCols = 2
objDoc.Tables.Add objRange, intRows, intCols
[COLOR=#ff0000][B] [I]objDoc.Tables.InsertAfter txtString[/I]
[/B][/COLOR]
Set objTable = objDoc.Tables(1)
objTable.Borders.Enable = True
With objTable
.Cell(1, 1).Range.Text = "My First Word VBA"
.Cell(2, 1).Range.Text = "Feedback"
End With
Set objWord = Nothing
End Sub
Last edited: