View Single Post
 
Old 05-21-2014, 07:58 AM
jpb103's Avatar
jpb103 jpb103 is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

This will help me for sure. Thanks pal!
I now have another problem though; I created a user form for the user to enter new items into the original table and I'm having problems loading the form data into the cells of a row object.
Code:
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
'Error handling for empty boxes
Dim msg, msg2, msg3 As String
msg = "You must enter a Description"
msg2 = "You must enter a Date"
msg3 = "You must enter a Priority"
If (DescriptionBox = "") Then
    MsgBox (msg)
ElseIf (DateBox = "") Then
    MsgBox (msg2)
ElseIf (PriorityCombo = "") Then
    MsgBox (msg3)
Else
    'No errors detected, add row to table and populate
    Dim oTbl As Word.Table
    Dim oRow As Row
    Dim oCol As Column
    Dim oRng As Word.Range
    Dim lngIndex As Long
    Dim lngCell As Long
    Set oTbl = ActiveDocument.Tables(1)
    oRow.Cells(0).Range.Text = DescriptionBox.Text
    oRow.Cells(1).Range.Text = DateBox.Text
    oRow.Cells(2).Range.Text = PriorityCombo.Text
    oRow.Cells(3).Range.Text = ActiveDocument.Tables(1).Rows(0).Cells(3).Range.Text
    ActiveDocument.Tables(1).Rows.Add oRow
    Unload Me
End If
End Sub
Private Sub UserForm_Initialize()
PriorityCombo.Clear
PriorityCombo.AddItem "Low"
PriorityCombo.AddItem "Medium"
PriorityCombo.AddItem "High"
End Sub
Reply With Quote