Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Assing Styles to the forms created in a table of Word .Dot file
i need to add a row to a existing table(with 3 coloums) by cliking a button
on the word doc.Then create from field in each coloums in the row and assign styles to each form field. Below is the code i have writtem , it assingns stylles only to the form field in the frist coloumn , n other form fields are assigned style of the type the table header is..... Private Sub Station_Click() With ActiveDocument 'unprotect file ActiveDocument.Unprotect Password:="" 'get current number of Rows: Dim iCount As Integer Dim iCell As Integer 'Add row iCount = ActiveDocument.Tables(2).Rows.Count If (iCount 6) Then ActiveDocument.Tables(2).Rows.Add Dim oFormfield As FormField Dim sName As String Dim sText As String Dim oRange As Range sText = "" sName = "" iCount = iCount + 1 Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(1).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(2).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(3).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Else MsgBox ("No more rows can be created") End If 'Reprotect file ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True End With End Sub |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
Assing Styles to the forms created in a table of Word .Dot file
Try
Private Sub Station_Click() Dim oFormfield As FormField Dim sText As String Dim oRange As Range Dim iCount As Long Dim icell As Long sText = "" With ActiveDocument 'unprotect file .Unprotect Password:="" 'get current number of Rows: iCount = .Tables(2).Rows.Count If (iCount 6) Then 'Add row .Tables(2).Rows.Add iCount = iCount + 1 For icell = 1 To 3 Set oRange = .Tables(2).Cell(iCount, icell).Range Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, _ Type:=wdFieldFormTextInput) With oFormfield .TextInput.Default = sText End With oRange.Style = .Styles("Station") Next Else MsgBox ("No more rows can be created") End If 'Reprotect file .Protect wdAllowOnlyFormFields, NoReset:=True End With End Sub -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Arthi" wrote in message ... i need to add a row to a existing table(with 3 coloums) by cliking a button on the word doc.Then create from field in each coloums in the row and assign styles to each form field. Below is the code i have writtem , it assingns stylles only to the form field in the frist coloumn , n other form fields are assigned style of the type the table header is..... Private Sub Station_Click() With ActiveDocument 'unprotect file ActiveDocument.Unprotect Password:="" 'get current number of Rows: Dim iCount As Integer Dim iCell As Integer 'Add row iCount = ActiveDocument.Tables(2).Rows.Count If (iCount 6) Then ActiveDocument.Tables(2).Rows.Add Dim oFormfield As FormField Dim sName As String Dim sText As String Dim oRange As Range sText = "" sName = "" iCount = iCount + 1 Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(1).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(2).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Set oRange = ActiveDocument.Tables(2).Rows(iCount).Cells(3).Ran ge Set oFormfield = ActiveDocument.FormFields.Add(Range:=oRange, Type:=wdFieldFormTextInput) sText = "" With oFormfield .TextInput.Default = sText .Select Selection.Style = ActiveDocument.Styles("Station") End With Else MsgBox ("No more rows can be created") End If 'Reprotect file ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True End With End Sub |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Converting WordPerfect 12 files to Word 2003 | New Users | |||
Mailmerge template | Mailmerge | |||
Converting Word Perfect forms to Word forms | Microsoft Word Help | |||
WP merge file to Word | Tables | |||
How can Word display full path of a file in the title bar? | Microsoft Word Help |