Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-24-2019, 01:58 AM
gmayor's Avatar
gmayor gmayor is offline vba detect first char in line and auto insert table Windows 10 vba detect first char in line and auto insert table Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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

Probably something like

Code:
Sub Macro1()
Dim oRng As Range
Dim oTable As Table
Dim oCell As Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(findText:="T. ")
            If oRng.Start = oRng.Paragraphs(1).Range.Start Then
                oRng.End = oRng.Paragraphs(1).Range.End
                oRng.Collapse 0
                Set oTable = ActiveDocument.Tables.Add(oRng, 2, 3)
                With oTable
                    .Columns(1).Width = CentimetersToPoints(1.17)
                    .Columns(2).Width = CentimetersToPoints(1.47)
                    .Columns(3).Width = CentimetersToPoints(13.35)
                    Set oCell = .Cell(1, 1).Range
                    oCell.End = oCell.End - 1
                    oCell.Text = "Date"
                    Set oCell = .Cell(1, 2).Range
                    oCell.End = oCell.End - 1
                    oCell.Text = "Initials"
                    Set oCell = .Cell(1, 3).Range
                    oCell.End = oCell.End - 1
                    oCell.Text = "Remarks"
                End With
            End If
        Loop
    End With
    Set oRng = Nothing
    Set oCell = Nothing
    Set oRng = 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
Auto insert of first line as file name on initial save elof69 Word 3 05-08-2019 11:05 PM
Auto insert table line johngav Word Tables 3 07-13-2017 08:44 AM
vba detect first char in line and auto insert table How to insert a line BEFORE a table in Word2007? pstein Word 12 10-29-2014 04:31 AM
How to insert a diagonal line across multiple cells in a Table? Joey Cheung Word Tables 1 10-10-2014 07:15 PM
auto-detect display options? davidt76 PowerPoint 0 09-30-2011 07:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:39 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