Select and copy text from cell and place in 2nd page header

T

Tisha

ARRRGGGHHHH!!!! Can someone please help me! I've created
a template form and I'm trying to program a macro so that
every time a 2nd or subsequent page is generated,
information from specific cells in a table on the first
page is automatically pasted into the cells of a table in
the 2nd page header (e.g., client, and product
information). In essence, I'm trying to perform a get text
function for text that has yet to be entered (when the
user opens the template and fills in this field
information it should then automatically pop into the
appropriate cells of the 2nd page header table) and it
doesn't seem to be working. Right now my code looks like
this:

ActiveDocument.Unprotect Password:=""
ActiveDocument.Tables(1).Rows(1).Cells(2).Range.Copy
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.NextHeaderFooter
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.MoveRight Unit:=wdCell
Set myRange = ActiveDocument.Range _
(Start:=ActiveDocument.Content.Tables(1).Rows
(1).Cells(1), _
End:=ActiveDocument.Content.Tables(1).Rows(1).Cells
(1))
myRange.Paste
ActiveDocument.Protect Password:="", NoReset:=False,
Type:= _
wdAllowOnlyFormFields
End Sub

I know I'm missing something that will make this run
properly, but I can't figure out what it is? How can I
get this to work?
 
J

Jean-Guy Marcil

Hi Tisha,

You do not need a macro for that.
Just go to the end of the first page in your template;
Hit CTRL-Enter;
Display the header;
Make sure you have it set as "First page different";
In the second page header, place REF fields to refer to the text fields from
the first page (Using CTRL-F9 to insert the curly braces and type in between
them something like: {REF Text1});
Lock up your form;
You will have to do a print preview to update the fields in the header, even
if you use the Calculate on exit property because the REF fields are in the
header.
You could have a little macro that does a quick PrintPreview then return to
normal view to update the fields (in the on exit event of the fields), but
it will not work until you actually have a second page).
--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

Tisha

Thank you so much Jean-Guy! You've saved what was left of
my sanity! I had completely forgotten about the REF Field
function and instead tried to make a mountain out of a
molehill by trying to create a rather complicated macro.
Thank you so much for taking the time to respond to my
post!
 
J

Jean-Guy Marcil

Glad to have saved you from a trip down medication lane!
You can expect a bill though... Psychotherapy does not come cheap!
;-)
--
Cheers!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org


"Tisha" <[email protected]> a écrit dans le message de
[email protected]...
Thank you so much Jean-Guy! You've saved what was left of
my sanity! I had completely forgotten about the REF Field
function and instead tried to make a mountain out of a
molehill by trying to create a rather complicated macro.
Thank you so much for taking the time to respond to my
post!
 

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