Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2012, 01:41 AM
tinfanide tinfanide is offline Word VBA: add textboxs in table cells? Windows 7 64bit Word VBA: add textboxs in table cells? Office 2010 32bit
Expert
Word VBA: add textboxs in table cells?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Code:
Sub test()

Dim File As String
File = "C:\Users\Tin\Desktop\Testing.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
oDoc.Activate


Dim lLeft As Long
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

 lLeft = tbl.Cell(2, 2).Range.Information(wdHorizontalPositionRelativeToPage)
  .Shapes.AddTextbox Orientation:=msoTextOrientationHorizontal, Left:=lLeft, _
    Top:=6, Width:=72, Height:=12, Anchor:=tbl.Cell(2, 2).Range.Characters.First


End With

End Sub
I have automated adding textboxes of Word in Excel VBA.
It seems to have put the textbox on the top left of the document. It does not put within the table cell.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA: add textboxs in table cells? put a border around table cells that have text in them tonywatsonmail Mail Merge 1 01-31-2012 04:37 AM
Word VBA: add textboxs in table cells? Unwanted tabs in table cells deltaskye Word 5 01-27-2012 11:58 AM
Word VBA: add textboxs in table cells? Combining Text from Table Cells robmorleyuk Word 1 11-01-2011 07:24 AM
Word VBA: add textboxs in table cells? Copy table cell formatting across multiple cells / tables pakistanray Word Tables 2 10-31-2011 08:07 AM
Word VBA: add textboxs in table cells? Share your tips for centering images in table cells WaltR Word 4 01-29-2011 11:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft