Private Sub DocControlAdd()
'Dim texta, textb, textc, textd, texte, textf As String 'this Dims all except the last variable as a variant
Dim texta As String, textb As String, textc As String, textd As String, texte As String, textf As String
Dim tbl As Table
Dim rw As Row
Dim cl As Cell
Dim c As Integer
Dim iStartCol As Integer
texta = ActiveDocument.CustomDocumentProperties.Item("xRevisionNo")
textb = ActiveDocument.CustomDocumentProperties.Item("xRevisionDate")
textc = ActiveDocument.CustomDocumentProperties.Item("xDetails")
textd = ActiveDocument.CustomDocumentProperties.Item("xPreparedby")
texte = ActiveDocument.CustomDocumentProperties.Item("xReviewedby")
textf = ActiveDocument.CustomDocumentProperties.Item("xApprovedby")
iStartCol = 1
Set tbl = ActiveDocument.Tables(1)
If ActiveDocument.CustomDocumentProperties.Item("xNew") = "Y" Then
Set rw = tbl.Rows.Add
ElseIf NewVersion = True Then
Set rw = tbl.Rows.Add
ElseIf NewVersion = False Then
tbl.Columns(iStartCol).Select
With Selection.Find
.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
If .Execute(FindText:=texta) Then
Set cl = Selection.Cells(1)
Set rw = tbl.Rows(cl.RowIndex)
End If
End With
End If
c = iStartCol
rw.Cells(c).Range.Text = texta
c = c + 1
rw.Cells(c).Range.Text = textb
c = c + 1
rw.Cells(c).Range.Text = textc
c = c + 1
rw.Cells(c).Range.Text = textd
c = c + 1
rw.Cells(c).Range.Text = texte
c = c + 1
rw.Cells(c).Range.Text = textf
ActiveDocument.CustomDocumentProperties.Item("xRevisionNoOld").Value = ActiveDocument.CustomDocumentProperties.Item("xRevisionNo").Value
End Sub
|