macro not running in form template - run time error 4605

L

Laina Lucas

I have recorded a macro to copy the text in a text field
and add it to the autotext (this way it will autocomplete
when used again). The problem is that when I save the
template and then run it (I have attached it to a field to
run on entry to that field, this is a field that is not
being copied by the macro) I get an error that tells
me "Run-time error '4605': The DisplayAutoCompleteTimps
method or property is not available because the object
referes to a protected area of the document."
How do I make the macro run? I have to have the template
protected and I also need to have the data put in the
autocomplete field.
Here is what the macro looks like:
Sub autofill()
'
' autofill Macro
' Macro recorded 2/1/2004 by Self
'
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1,
Extend:=wdExtend
Application.DisplayAutoCompleteTips = True

Thanks,
Laina
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Laina,

You will have to include the command ActiveDocument.Unprotect to remove the
protection at the beginning of the macro and use ActiveDocument.Protect
wdAllowOnlyFormFields, NoReset at the end of it to re-apply the protection
so that the balance of your formfields work.

I can't really tell what the code that you have posted is doing, so I am not
sure that the above alone will cure all your problems. It should however
prevent the message that you are presently seeing.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

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

Similar Threads


Top