Hi tinfanide,
It seems something's changed about the way Word 2010 implements this. Try:
Code:
Sub TypeTextTypeUnderline()
Dim File As String, oWord As Word.Application, oDoc As Word.Document
Dim tbl As Word.Table, Shp As Word.Shape, Rng As Word.Range
Dim SngLeft As Single, SngTop As Single
File = "C:\Users\Tin\Desktop\a.docx"
Set oWord = New Word.Application
oWord.Visible = True
Set oDoc = oWord.Documents.Open(File)
With oDoc
Set tbl = .Tables.Add(Range:=.Range, NumRows:=2, NumColumns:=2, _
DefaultTableBehavior:=wdWord8TableBehavior)
With tbl
.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
.Borders(wdBorderRight).LineStyle = wdLineStyleSingle
.Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
.Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
.Borders(wdBorderVertical).LineStyle = wdLineStyleSingle
Set Rng = .Cell(2, 2).Range
Rng.Collapse wdCollapseStart
SngLeft = Rng.Information(wdHorizontalPositionRelativeToPage)
SngTop = Rng.Information(wdVerticalPositionRelativeToPage)
End With
Set Shp = oDoc.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=SngLeft, Top:=SngTop, Width:=72, Height:=12, Anchor:=Rng)
With Shp
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
End With
End With
End Sub