Automate filling in protected forms
There are a number of ways to run a macro on a protected form:
1. On Entry or Exit from a formfield
2. By assigning the macro to the keyboard
3. By assigning the macro to a button on the toolbar.
However, you are probably not going to be able to record a macro for what
you want to do.
You will need to do something like
Dim target as Document, source as Document, datatable as Table, data as
Range
Set target = ActiveDocument 'the protected form document
Set source = Documents.Open("drive\path\filename") 'the document containing
the table
Set datatable = source.Tables(1) 'assumes that the data is in the first
table in the document
Set data=datatable.cells(r#, c#).Range
data.end=data.end - 1
target.formfields("name").Result = data
The last several lines of this code will have to be tailored to your actual
requirements.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"wurstfreund" wrote in message
...
On a daily basis I have to fill in a form the same way based on a table in
another Word document.
Is there a way I can automate this process? I'm frustrated to find that I
can't run a macro on a protected form. I can easily unprotect the form,
but
this makes the process of recording the macro much more difficult (more
fields to navigate etc.)
Any suggestions?
|