B
Brian Lanehart
Hello,
I have an empty word document that only has 1 table that has 2 columns
& 5 rows. In cell(1,1), I have: January 1,2010 and all I am trying to
do in VBA is convert that to a date so that I can do some date math
functions, but I can't seem to convert it to date.
In the VBA code, i have:
Private Sub Document_New()
Dim tbl As Table
Dim day1 As String
Dim day2 As Date
Set tbl = ActiveDocument.Tables(1)
day1 = (tbl.Cell(1, 1).Range.Text)
day2 = (tbl.Cell(1, 1).Range.Text)
End Sub
However, "day2 = (tbl.Cell(1, 1).Range.Text)" gives me a type mismatch
as does "day2 = CDate((tbl.Cell(1, 1).Range.Text))" but doing:
"tbl.Rows(2).Cells(2).Range.Text = CDate("January 1,2010")" doe NOT
give a type mismatch.
Will someone help me understand why?
thank you!
-brian
I have an empty word document that only has 1 table that has 2 columns
& 5 rows. In cell(1,1), I have: January 1,2010 and all I am trying to
do in VBA is convert that to a date so that I can do some date math
functions, but I can't seem to convert it to date.
In the VBA code, i have:
Private Sub Document_New()
Dim tbl As Table
Dim day1 As String
Dim day2 As Date
Set tbl = ActiveDocument.Tables(1)
day1 = (tbl.Cell(1, 1).Range.Text)
day2 = (tbl.Cell(1, 1).Range.Text)
End Sub
However, "day2 = (tbl.Cell(1, 1).Range.Text)" gives me a type mismatch
as does "day2 = CDate((tbl.Cell(1, 1).Range.Text))" but doing:
"tbl.Rows(2).Cells(2).Range.Text = CDate("January 1,2010")" doe NOT
give a type mismatch.
Will someone help me understand why?
thank you!
-brian