Filling a protected form

F

Fred

I have a protected form that I wish to fill in using VBA but I keep get the
message that I am trying to type into a protected area.
I can manually type text into this form so why can't I do the same in VBA

When I record a macro as I type into the form I get something like

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 22/06/07 by Fred Schreuder
'
Windows(1).Activate
Selection.TypeText Text:="Consignee"
Windows(2).Activate
End Sub

but if I then try to run the macro I get an error about a protect area.
I am not trying to bypass any protection I just want to be able to
automatically fillin the form as I would do when I type in the data.

Can some please tell me if this is possible with trying to unprotect the
document.

thanks
Fred
 
B

Bear

Fred:

I'm lazy this morning, so I haven't built a test document like yours to make
sure of what I'm saying. But I think you're having trouble because when you
use the GUI, you've used the form function to select the formfield result
area to type into. When you do this through VBA, you haven't conveyed that to
the form function, which thinks you're just trying to type somewhere in the
protected area.

No matter the cause.

If you write code that alters the formfield value or result, you can do that
without unprotecting the document. Code would look something like:

ActiveDocument.FormFields("txtCopyFor").Result = "Consignee"

Where "txtCopyFor" is the bookmark used to identfy the formfield.

Bear
 

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