T
Tendresse
Hi all,
I keep getting the above error message every time i try to open a certain
template. From what i read so far, this problem may be due to a 'corrupt'
template. I need some clarification around that. How can a template be
'corrupt'? it was working perfectly fine for nearly 2 weeks before i start
getting this error. How can a template suddenly becomes 'corrupt'? If i
re-design the template, would this solve the problem? but how to prevent it
from happening again?
My template contains one control button that runs the following macro:
Any help will be greatly appreciated. I use windows 2003.
Sub Add_person()
' Macro to add a new row in a table to record person's details
' the new row contains 7 cells
' Unprotect document
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
End If
' Move to the last cell in the table and press TAB to enter new row
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCell, Count:=7
' Enter Text Fields in first 2 cells in the new row
Dim i As Integer
For i = 1 To 2
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Next i
' Enter drop down list for 'Gender' in the third cell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="Male"
.Add name:="Female"
.Add name:="Unknown"
End With
' Move to next cell and add drop down list for Indigenous Status
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="Aboriginal"
.Add name:="Torres Strait Islander"
.Add name:="Both"
.Add name:="Neither"
.Add name:="Unknown"
End With
' Move to next cell and add drop down list for Language
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="English"
.Add name:="Indigenous"
.Add name:="Arabic"
.Add name:="Cantonese"
.Add name:="Croatian"
.Add name:="Greek"
.Add name:="Italian"
.Add name:="Japanese"
.Add name:="Korean"
.Add name:="Mandarin"
.Add name:="Polish"
.Add name:="Samoan"
.Add name:="Spanish"
.Add name:="Vietnamese"
.Add name:="Other"
.Add name:="Unknown"
End With
' Move next and enter free text box in the next 2 cells
Dim x As Integer
For x = 1 To 2
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormTextInput
Selection.PreviousField.Select
With Selection.FormFields(1)
With .TextInput
.EditType Type:=wdRegularText, Default:="As Above", Format:=""
.Width = 0
End With
End With
Next x
' Select the first Text Field in the new row
Selection.MoveLeft Unit:=wdWord, Count:=12
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
' Protect
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect wdAllowOnlyFormFields, True, "password"
End If
End Sub
I keep getting the above error message every time i try to open a certain
template. From what i read so far, this problem may be due to a 'corrupt'
template. I need some clarification around that. How can a template be
'corrupt'? it was working perfectly fine for nearly 2 weeks before i start
getting this error. How can a template suddenly becomes 'corrupt'? If i
re-design the template, would this solve the problem? but how to prevent it
from happening again?
My template contains one control button that runs the following macro:
Any help will be greatly appreciated. I use windows 2003.
Sub Add_person()
' Macro to add a new row in a table to record person's details
' the new row contains 7 cells
' Unprotect document
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
End If
' Move to the last cell in the table and press TAB to enter new row
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCell, Count:=7
' Enter Text Fields in first 2 cells in the new row
Dim i As Integer
For i = 1 To 2
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormTextInput
Selection.MoveRight Unit:=wdCell
Next i
' Enter drop down list for 'Gender' in the third cell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="Male"
.Add name:="Female"
.Add name:="Unknown"
End With
' Move to next cell and add drop down list for Indigenous Status
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="Aboriginal"
.Add name:="Torres Strait Islander"
.Add name:="Both"
.Add name:="Neither"
.Add name:="Unknown"
End With
' Move to next cell and add drop down list for Language
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1).DropDown.ListEntries
.Add name:="Select"
.Add name:="English"
.Add name:="Indigenous"
.Add name:="Arabic"
.Add name:="Cantonese"
.Add name:="Croatian"
.Add name:="Greek"
.Add name:="Italian"
.Add name:="Japanese"
.Add name:="Korean"
.Add name:="Mandarin"
.Add name:="Polish"
.Add name:="Samoan"
.Add name:="Spanish"
.Add name:="Vietnamese"
.Add name:="Other"
.Add name:="Unknown"
End With
' Move next and enter free text box in the next 2 cells
Dim x As Integer
For x = 1 To 2
Selection.MoveRight Unit:=wdCell
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormTextInput
Selection.PreviousField.Select
With Selection.FormFields(1)
With .TextInput
.EditType Type:=wdRegularText, Default:="As Above", Format:=""
.Width = 0
End With
End With
Next x
' Select the first Text Field in the new row
Selection.MoveLeft Unit:=wdWord, Count:=12
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
' Protect
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect wdAllowOnlyFormFields, True, "password"
End If
End Sub