Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
Arthi Arthi is offline
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting WordPerfect 12 files to Word 2003 Curious New Users 4 May 19th 23 02:48 PM
Mailmerge template stephen Mailmerge 8 August 18th 06 02:19 PM
Converting Word Perfect forms to Word forms elyse Microsoft Word Help 1 February 15th 06 09:17 PM
WP merge file to Word sstires Tables 4 February 14th 06 07:26 PM
How can Word display full path of a file in the title bar? SAsif Microsoft Word Help 1 January 26th 06 05:32 PM


All times are GMT +1. The time now is 02:30 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"