Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata
Public Sub Format()

'Clear Table
If ActiveDocument.Tables.Count >= 1 Then
 ActiveDocument.Tables(1).Delete
End If

'Create Table
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:=2
Dim tbl As Table
Set tbl = ActiveDocument.Tables(1)

'Add EmpName
With tbl.Cell(1, 1).Range
 .Text = "Employee Name:"
 .Font.Name = "Times New Roman"
 .Font.Size = 12
 .Font.Bold = True
 .Font.Underline = True
 .ParagraphFormat.Alignment = wdAlignParagraphRight
End With

With tbl.Cell(1, 2).Range
 .Text = EmpName
 .Font.Name = "Times New Roman"
 .Font.Size = 12
 .Font.Bold = True
 .Font.Underline = True
 .ParagraphFormat.Alignment = wdAlignParagraphLeft
End With

'Add EmpNum
With tbl.Cell(2, 1).Range
 .Text = "Employee Number:"
 .Font.Name = "Times New Roman"
 .Font.Size = 12
 .Font.Bold = True
 .Font.Underline = True
 .ParagraphFormat.Alignment = wdAlignParagraphRight
End With

With tbl.Cell(2, 2).Range
 .Text = EmpNum
 .Font.Name = "Times New Roman"
 .Font.Size = 12
 .Font.Bold = True
 .Font.Underline = True
 .ParagraphFormat.Alignment = wdAlignParagraphLeft
End With

'Barcode!
With tbl.Cell(3, 1).Range
 .Text = EmpNumCode39
 .Font.Name = "Free 3 of 9 Extended"
 .Font.Size = 152
End With

'Borders
tbl.Borders.Enable = True

'Merge Last Row
tbl.Cell(Row:=3, Column:=1).Merge MergeTo:=tbl.Cell(Row:=3, Column:=2)
tbl.AutoFitBehavior wdAutoFitContent
tbl.Cell(3, 1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
tbl.Cell(3, 1).Borders.Enable = False
End Sub


  • No labels