Hi everybody.
I have a word documend with formfields, TextInput, DropDown and CheckBox. In one of the pages I allow the users to duplicate that page by inserting a new section in the document and copying everything in the range of the precedent section. Everything goes Ok, all fields are updated with the exception of the DropDown and CheckBox. It's my first work in VBA (I'm PowerBuilder ) I'm stuck and the work must be ready quick.
I join the code and maybe some one can help me and/or correct this, before I go nuts
Private Sub CommandButton1_Click()
ActiveDocument.Unprotect Password:="W8ynfLP" '
fcount = ActiveDocument.Fields.Count
ReDim aFields(fcount)
For Each aField In ActiveDocument.Fields
aFields(aField.Index) = aField.Result
Next aField
ActiveDocument.FormFields("t_endA2".Select
Selection.MoveUp Unit:=wdLine, Count:=1
li_section = ActiveDocument.Sections.Count
Set aDoc = ActiveDocument
Set myRange = aDoc.Range(aDoc.Sections(li_section).Range.Start, End:=Selection.End)
myRange.Copy
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.PasteAndFormat (wdPasteDefault)
ActiveDocument.Protect Password:="W8ynfLP", NoReset:=False, Type:= _
wdAllowOnlyFormFields
For Each aField In ActiveDocument.Fields
aField.Result = aFields(aField.Index)
Next aField
End Sub
Any help is welcome!
Thanks
Francisco Carreta
I have a word documend with formfields, TextInput, DropDown and CheckBox. In one of the pages I allow the users to duplicate that page by inserting a new section in the document and copying everything in the range of the precedent section. Everything goes Ok, all fields are updated with the exception of the DropDown and CheckBox. It's my first work in VBA (I'm PowerBuilder ) I'm stuck and the work must be ready quick.
I join the code and maybe some one can help me and/or correct this, before I go nuts
Private Sub CommandButton1_Click()
ActiveDocument.Unprotect Password:="W8ynfLP" '
fcount = ActiveDocument.Fields.Count
ReDim aFields(fcount)
For Each aField In ActiveDocument.Fields
aFields(aField.Index) = aField.Result
Next aField
ActiveDocument.FormFields("t_endA2".Select
Selection.MoveUp Unit:=wdLine, Count:=1
li_section = ActiveDocument.Sections.Count
Set aDoc = ActiveDocument
Set myRange = aDoc.Range(aDoc.Sections(li_section).Range.Start, End:=Selection.End)
myRange.Copy
Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.PasteAndFormat (wdPasteDefault)
ActiveDocument.Protect Password:="W8ynfLP", NoReset:=False, Type:= _
wdAllowOnlyFormFields
For Each aField In ActiveDocument.Fields
aField.Result = aFields(aField.Index)
Next aField
End Sub
Any help is welcome!
Thanks
Francisco Carreta