how to insert text form field into a table in word application with vb6

L

Lee.Hollowood

Hi,

I have tried some ways to insert a text form field into a cell of the
table but failed. Could someone give me some clues how to code it. the
text form field is inserted into 4th column.
My code is as follow:

Set otable = doc.Tables.Add(doc.Bookmarks("sii").Range, nrRow, 4)
With otable
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.Range.Font.Size = 10
.Range.Font.Name = "Times New Roman"
.Range.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter
' Insert titles into the first cell in the second row of the table
.Cell(1, 1).Range.InsertBefore "Test Method"
.Cell(1, 2).Range.InsertBefore "Component"
.Cell(1, 3).Range.InsertBefore "Specifications"
.Cell(1, 4).Range.InsertBefore "Actual"
' Insert data into table

' the 4th column are inserted into with a text form field (shadow
area with text on it)

For i = 1 To nrRow Step 1
.Cell(i + 1, 1).Range.InsertBefore cell1(i - 1)
.Cell(i + 1, 2).Range.InsertBefore cell2(i - 1)
.Cell(i + 1, 3).Range.InsertBefore cell3(i - 1)
.Cell(i + 1, 4).Range.InsertBefore cell4(i - 1)
Next
End With

Thank you

Hollowood
 
C

Cindy M.

I have tried some ways to insert a text form field into a cell of the
table but failed. Could someone give me some clues how to code it. the
text form field is inserted into 4th column.
My code is as follow:
Mmmm. The comments in your code don't match what the code is doing, but
this is how I'd put a TextInput type of form field into the second row,
fourth column of a table:

Dim rng As Word.Range
Dim ffld As Word.FormField

Set rng = tbl.Cell(2, 4).Range
rng.Collapse wdCollapseStart
Set ffld = ActiveDocument.FormFields.Add( _
rng, wdFieldFormTextInput)
ffld.Name = "TextX"

Set otable = doc.Tables.Add(doc.Bookmarks("sii").Range, nrRow, 4)
With otable
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.Range.Font.Size = 10
.Range.Font.Name = "Times New Roman"
.Range.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter
' Insert titles into the first cell in the second row of the table
.Cell(1, 1).Range.InsertBefore "Test Method"
.Cell(1, 2).Range.InsertBefore "Component"
.Cell(1, 3).Range.InsertBefore "Specifications"
.Cell(1, 4).Range.InsertBefore "Actual"
' Insert data into table

' the 4th column are inserted into with a text form field (shadow
area with text on it)

For i = 1 To nrRow Step 1
.Cell(i + 1, 1).Range.InsertBefore cell1(i - 1)
.Cell(i + 1, 2).Range.InsertBefore cell2(i - 1)
.Cell(i + 1, 3).Range.InsertBefore cell3(i - 1)
.Cell(i + 1, 4).Range.InsertBefore cell4(i - 1)
Next
End With

Thank you

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
D

David Brown

I have a word doc (.dot), I am trying to use code to insert into the formfields of the word doc. I can loop thru the word doc and find all the formfields, but unable to insert text into the formfields as I am looping thru.

For Each drow_getMailInfo As DataRow In DataTable_MailInfo.Rows

myWordDoc = myWordApp.Documents.Add(filename, missing, missing, missing)

Dim string_formfield As String = ""
Dim string_Enclosures As Boolean = False

For Each formfield As Word.FormField In myWordDoc.FormFields
string_formfield = formfield.Name.ToString

If string_formfield = "ENCLOSURES" Then
string_Enclosures = True

Else
string_formfield = drow_getMailInfo.Item("" & string_formfield & "").ToString.Trim

End If


Next




Cindy M. wrote:

Mmmm.
30-May-07

Mmmm. The comments in your code don't match what the code is doing, but
this is how I'd put a TextInput type of form field into the second row,
fourth column of a table

Dim rng As Word.Rang
Dim ffld As Word.FormFiel

Set rng = tbl.Cell(2, 4).Rang
rng.Collapse wdCollapseStar
Set ffld = ActiveDocument.FormFields.Add(
rng, wdFieldFormTextInput
ffld.Name = "TextX


Cindy Meiste
INTER-Solutions, Switzerlan
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005
http://www.word.mvps.or

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)

Previous Posts In This Thread:

how to insert text form field into a table in word application with vb6
Hi

I have tried some ways to insert a text form field into a cell of th
table but failed. Could someone give me some clues how to code it. th
text form field is inserted into 4th column
My code is as follow

Set otable = doc.Tables.Add(doc.Bookmarks("sii").Range, nrRow, 4
With otabl
If .Style <> "Table Grid" The
.Style = "Table Grid
End I
.Range.Font.Size = 1
.Range.Font.Name = "Times New Roman
.Range.ParagraphFormat.Alignment
Word.WdParagraphAlignment.wdAlignParagraphCente
' Insert titles into the first cell in the second row of the tabl
.Cell(1, 1).Range.InsertBefore "Test Method
.Cell(1, 2).Range.InsertBefore "Component
.Cell(1, 3).Range.InsertBefore "Specifications
.Cell(1, 4).Range.InsertBefore "Actual
' Insert data into tabl

' the 4th column are inserted into with a text form field (shado
area with text on it

For i = 1 To nrRow Step
.Cell(i + 1, 1).Range.InsertBefore cell1(i - 1
.Cell(i + 1, 2).Range.InsertBefore cell2(i - 1
.Cell(i + 1, 3).Range.InsertBefore cell3(i - 1
.Cell(i + 1, 4).Range.InsertBefore cell4(i - 1
Nex
End Wit

Thank yo

Hollowood

Mmmm.
Mmmm. The comments in your code don't match what the code is doing, but
this is how I'd put a TextInput type of form field into the second row,
fourth column of a table

Dim rng As Word.Rang
Dim ffld As Word.FormFiel

Set rng = tbl.Cell(2, 4).Rang
rng.Collapse wdCollapseStar
Set ffld = ActiveDocument.FormFields.Add(
rng, wdFieldFormTextInput
ffld.Name = "TextX


Cindy Meiste
INTER-Solutions, Switzerlan
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005
http://www.word.mvps.or

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)


Submitted via EggHeadCafe - Software Developer Portal of Choice
Javascript OK/Cancel Message Box Example
http://www.eggheadcafe.com/tutorial...25-6df4b8de84c0/javascript-okcancel-mess.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top