Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 08-03-2019, 08:04 PM
gmayor's Avatar
gmayor gmayor is offline syntax for inserting blank line before inserting table and after a line or paragraph Windows 10 syntax for inserting blank line before inserting table and after a line or paragraph Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

To add a line after the table, you need to reset the range e.g.

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
Dim oCell As Object

    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
        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


    '''''Here also  i would like blank line and start
    txtword = "Paragraph / Line after table"

    Set objRange = objDoc.Range

    With objRange
        .collapse Direction:=0
        .Text = txtword & vbCr    'add the paragraph break at the end of the text string
    End With
    '''''The above range started in the table of 1st Row

    Set objWord = Nothing
    Set objDoc = Nothing
    Set objRange = Nothing
    Set objTable = Nothing
    Set oCell = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax for inserting blank line before inserting table and after a line or paragraph Sparse words in line when inserting a link titanic Word 4 11-12-2018 01:50 PM
syntax for inserting blank line before inserting table and after a line or paragraph Inserting code line in Word Module mihnea96 Excel Programming 2 08-15-2017 04:57 AM
syntax for inserting blank line before inserting table and after a line or paragraph Word inserting line breaks / wrapping text Girloutside Word 1 08-10-2015 12:45 PM
syntax for inserting blank line before inserting table and after a line or paragraph inserting wordwrap table causes paragraph break in text sodiumkpump Word Tables 1 08-05-2015 06:36 PM
syntax for inserting blank line before inserting table and after a line or paragraph Inserting key strokes with a macro line ACA Word VBA 4 12-03-2012 04:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft