View Single Post
 
Old 02-06-2012, 06:07 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Code:
Sub TypeTextTypeUnderline()
 
Dim File As String
File = "C:\Users\Tin\Desktop\a.docx"
 
Dim oWord As Word.Application
Set oWord = New Word.Application
Dim oDoc As Word.Document
Set oDoc = oWord.Documents.Open(File)
oWord.Visible = True
 
Dim tbl As Word.Table

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
    End With
 
 
End With

Dim Shp As Word.Shape
Dim Rng As Word.Range
With oDoc
Set Rng = .Tables(1).Cell(2, 2).Range
    Rng.Collapse wdCollapseStart
    Set Shp = oDoc.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
      Left:=0, Top:=0, Width:=72, Height:=12, Anchor:=Rng)
  With Shp
    .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
    .RelativeVerticalPosition = wdRelativeVerticalPositionPage
  End With
End With
 
End Sub
Sorry, even though it was changed as ya said, but I still could not figure out why the textbox stays at the right top left of the page.
Reply With Quote