A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Assing Styles to the forms created in a table of Word .Dot file



 
 
Thread Tools Display Modes
  #1  
Old October 31st, 2006, 02:55 PM posted to microsoft.public.word.tables
Arthi
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  
Old October 31st, 2006, 07:39 PM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.