View Single Post
 
Old 08-06-2019, 02:58 AM
SamDsouza SamDsouza is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Having tried the below code


Private Sub InsertingBlankLine()
Dim oWord As Object
Dim oDoc As Object
Dim oCell As Object, txtWord as String

txtword = "To," & vbCrLf & "Add1," & vbCrLf & "Add2" & vbCrLf & "Add3" & vbCrLf & _
"Date : " & TextBox1.Text & vbCrLf & vbCrLf & " " & TextBox2.Text & vbCrLf & _
"Sub : " & vbCrLf & vbCrLf & "Dear Sir/Madam" & vbCrLf & _
" " & TextBox3.Text & " With a request to fdljfljdljf kdfhdfhdhfdfhd" & vbCrLf & _
"sjfhksdfhdskfhdsfkds / XXX. hbxczkdhsakdhsdjshkdjsh."

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = CreateObject("Word.Application")
End If
On Error GoTo 0
Set oDoc = oWord.Documents.Add
oWord.Visible = True
With oDoc
'.Content = "kdhfdskfhd fkdshfdkfhdskfhdsfd fdshgfdjdsjfg" & vbCr & vbCr & "Paragraph / Line after table"
.Content = txtWord
'''''''''' The Content Breaks or txtWord breaks and Table is inserted as it breaks and inserts the table and it reads the first 1 sentence of txtWord and not the full content or TxtWord
how can i close or collapse the content here to get full content or full txtword then add the table with continuing below code


.Tables.Add .Paragraphs(2).Range, 8, 5
With .Tables(1)
.Borders.Enable = True
Set oCell = .Cell(1, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 1"
oCell.Bold = True
Set oCell = .Cell(2, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 2"
Set oCell = .Cell(3, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 3"
Set oCell = .Cell(4, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 4"
Set oCell = .Cell(5, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 5"
Set oCell = .Cell(6, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 6"
Set oCell = .Cell(7, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 7"
Set oCell = .Cell(8, 1).Range
oCell.End = oCell.End - 1
oCell.Text = "row 8"
.Range.Font.Name = "Tahoma"
.Range.Font.Size = 15
End With
End With
Add another txtWord or new Paragraph after the table. Collapse or end it then
Add another table at different position in the same line after New txtWord or new paragraph as show in doc file


Set oWord = Nothing
Set oDoc = Nothing
Set oCell = Nothing
End Sub

Your help will be highly appreciated
SamD
Reply With Quote