![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Alternatively:
Code:
Private Sub InsertingBlankLine()
Dim oWord As Word.Application
Dim oDoc As Document
Dim oRng As Range
Dim oTbl As Table
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oDoc = oWord.Documents.Add
Set oTbl = oDoc.Tables.Add(oDoc.Range, 8, 5)
Set oRng = oTbl.Range
oTbl.Borders.Enable = True
oRng.Collapse wdCollapseStart
oRng.InsertBreak Type:=wdColumnBreak
oRng.Text = "fsdhfkhfkdhfdskfhd fkdshfdkfhdskfhdsfd fdshgfdjdsjfg"
End Sub
|
|
#2
|
|||
|
|||
|
Thanks Andrew Lockton (Guessed) . You realy made me my first .Docm file with your coding. Indeed it strated off with VBA word
the begining was perfect Thanks to you Gmayor Yes i started from Excel. It is just what i wanted but then i thought i could move on but got stuck when i wanted to insert again new line after the table As this got me more intrested added and modified with your code in RED Code:
Private Sub InsertingBlankLine()
Dim objWord As Object
Dim txtword As String, sh As Worksheet
Dim objDoc As Object
Dim objRange As Object
Dim objTable As Object
Dim intRows As Integer
Dim intCols As Integer
txtword = "fsdhfkhfkdhfdskfhd fkdshfdkfhdskfhdsfd fdshgfdjdsjfg"
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
If Err Then
Set objWord = CreateObject("Word.Application")
End If
On Error GoTo 0
Set objDoc = objWord.Documents.Add
objWord.Visible = True
Set objRange = objDoc.Range
With objRange
.Text = txtword & vbCr 'add the paragraph break at the end of the text string
.Collapse Direction:=0
End With
intRows = 8: intCols = 5
Set objTable = objDoc.Tables.Add(objRange, intRows, intCols)
'''''''objTable.Borders.Enable = True
With objTable
.Borders.Enable = True
.Cell(1, 1).Range.Text = "row 1"
.Cell(1, 1).Range.Bold = True
.Cell(2, 1).Range.Text = "row 2"
.Cell(3, 1).Range.Text = "row 3"
.Cell(4, 1).Range.Text = "row 4"
.Cell(5, 1).Range.Text = "row 5"
.Cell(6, 1).Range.Text = "row 6"
.Cell(7, 1).Range.Text = "row 7"
.Cell(8, 1).Range.Text = "row 8"
.Range.Font.Name = "Tahoma"
.Range.Font.Size = 15
End With
Set objTable = Nothing
'''''Here also i would like blank line and start
txtword = "Paragraph / Line after table"
With objRange
.Text = txtword & vbCr 'add the paragraph break at the end of the text string
.Collapse Direction:=0
End With
'''''The above range started in the table of 1st Row
Set objWord = Nothing
Set objDoc = Nothing
Set objRange = Nothing
'''''' Set objTable = Nothing
End Sub
at Set oRng = oTbl.Range Glad to be here on this forum Thank you guys SamD |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Sparse words in line when inserting a link
|
titanic | Word | 4 | 11-12-2018 01:50 PM |
Inserting code line in Word Module
|
mihnea96 | Excel Programming | 2 | 08-15-2017 04:57 AM |
Word inserting line breaks / wrapping text
|
Girloutside | Word | 1 | 08-10-2015 12:45 PM |
inserting wordwrap table causes paragraph break in text
|
sodiumkpump | Word Tables | 1 | 08-05-2015 06:36 PM |
Inserting key strokes with a macro line
|
ACA | Word VBA | 4 | 12-03-2012 04:40 AM |