Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automaticly add Textfield (forms) at new table row after adding

Status
Not open for further replies.

xenofoob

Programmer
Oct 4, 2004
28
NL
Hello,

I hope my subject is clear enough :) I've got a form with some fields.

It is actually a document where I want to fill in some products per line.

Product name | Amount | Price

When hitting the TAB button after filling in the price there should be a table row added with an empty fields.

Does anyone knows a solution for my problem? Is it even possible???

-Erik-
 
very possible.

when u stop though? make new row...tab, tab, tab...make new row..tab, tab, tab...make new row

when u stop?
 
It depends on how much items I want to place. That is not a certain number.

I've tried to record a macro (tab -> new row -> add field, tab -> add field -> edit properties, tab -> add field -> edit properties, and stop record) and I've got the following code:

Sub autoadd()
'
' autoadd Macro
' Macro opgenomen op 23-11-2004 door E. Holman
'
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With Selection.FormFields(1)
.Name = "Text15"
.EntryMacro = ""
.ExitMacro = ""
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdNumberText, Default:="", Format:=""
.Width = 0
End With
End With
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="€ "
Selection.FormFields.Add Range:=Selection.Range, Type:= _
wdFieldFormTextInput
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With Selection.FormFields(1)
.Name = "Text16"
.EntryMacro = ""
.ExitMacro = "autoadd"
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
With .TextInput
.EditType Type:=wdNumberText, Default:="", Format:="0,00"
.Width = 0
End With
End With
End Sub
=================================================

Becouse my form is protected or so I get an error at this line: Selection.MoveRight Unit:=wdCell

Any idea?
 
The solution is to remove the protection :)
Code:
    ActiveDocument.Unprotect
    [..macro code..]
    ActiveDocument.Protect wdAllowOnlyFormFields
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top