Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
wurstfreund
 
Posts: n/a
Default Automate filling in protected forms

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?
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP
 
Posts: n/a
Default 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?



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
wurstfreund
 
Posts: n/a
Default Automate filling in protected forms

This is extraordinarily helpful. I have one additional question, though.
In trying to implement this, I'm having trouble specifying the range of
cells I would like to use as my range.
The cells are all in row 1, columns 1-27 of the first table in my source
document. Perhaps I'm using incorrect syntax to specify them, but the VB
Debugger keeps saying the method or data member is not found. Here's what I
have:

Dim target As Document, source As Document, datatable As Table, data As Range
Set target = ActiveDocument 'the protected form document
Set source = Documents.Open("c:\documents and
settings\xxxxxx\desktop\foo.doc") '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(R1, C1 - 27).Range
data.End = data.End - 1
target.FormFields(1 - 27).Result = data

Thanks for your help!

"Doug Robbins - Word MVP" wrote:

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?




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP
 
Posts: n/a
Default Automate filling in protected forms

Dim target As Document, source As Document, datatable As Table, data As
Range, i as Long, ff as string
Set target = ActiveDocument 'the protected form document
Set source = Documents.Open("c:\documents and
settings\xxxxxx\desktop\foo.doc") 'the document containing the Table
Set datatable = source.Tables(1) 'assumes that the data is in the first
'table in the document
For i = 1 to 27
Set data = datatable.Cells(1, i).Range
data.End = data.End - 1
ff = "text" & i
target.FormFields(ff).Result = data
Next i

This assumes that the formfields have the following bookmark names assigned
to them - text1, text2, text3, .... text27

--
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
...
This is extraordinarily helpful. I have one additional question, though.
In trying to implement this, I'm having trouble specifying the range of
cells I would like to use as my range.
The cells are all in row 1, columns 1-27 of the first table in my source
document. Perhaps I'm using incorrect syntax to specify them, but the VB
Debugger keeps saying the method or data member is not found. Here's what
I
have:

Dim target As Document, source As Document, datatable As Table, data As
Range
Set target = ActiveDocument 'the protected form document
Set source = Documents.Open("c:\documents and
settings\xxxxxx\desktop\foo.doc") '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(R1, C1 - 27).Range
data.End = data.End - 1
target.FormFields(1 - 27).Result = data

Thanks for your help!

"Doug Robbins - Word MVP" wrote:

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?






Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Protected Forms that calculate... Beck Microsoft Word Help 1 October 28th 05 06:14 PM
Insert Footnotes within protected word forms Karine MCAB Microsoft Word Help 1 October 17th 05 06:43 PM
Envelopes and Protected Forms Jason Roberts Microsoft Word Help 4 August 19th 05 03:54 PM
Links in protected forms? Fia Microsoft Word Help 2 February 24th 05 11:13 AM
Filling out forms on computer instead of typewriter dking Microsoft Word Help 2 February 9th 05 02:55 AM


All times are GMT +1. The time now is 10:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"