Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Filling a protected form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 22 Jun 2007 06:15 GMT
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
Bear - 22 Jun 2007 15:01 GMT
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
Signature

Windows XP, Word 2000

Fred - 24 Jun 2007 21:49 GMT
Thanks Bear, that worked.

Fred

> Fred:
>
[quoted text clipped - 20 lines]
>
> Bear
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.