VBA Formfield Errors autotext insertion

N

NateB

Help required please. In dropdown formfield autotext is not consistently inserting attached template auototext tables. Code is below. The template has three sections - two protected. one unprotected. I got code from Microsoft online.

Sometimes it inserts the autotext other times it throws and error.

I am running SP3 WinXP Word 2003.

Sub DDAutotext1()

'DropDown Autotext


Dim DropResult As String

' Get result of the form field.
DropResult = ActiveDocument.FormFields("Dropdown1").Result

' UnProtect the document.
ActiveDocument.Unprotect

Call DeleteSubject

With Selection


' Go to location to insert Autotext

.GoTo What:=wdGoToBookmark, Name:="Table1"

' Insert AutoText name chosen from dropdown list
'.InsertAfter DropResult

' Insert the AutoText
.Range.InsertAutoText '***This line falls over more often than not and unprotects the form when it does.

End With

' If ActiveDocument.Bookmarks("StartHere") = True Then

' Selection.GoTo What:=wdGoToBookmark, Name:="StartHere"

' End If


' Re-Protect the document.


If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top