Macro which will run if doc goes to more than one page

J

Jacqui

I have a document template which may or may not be two or more pages
long but in some case only 1. What I want to do is create a macro
that will show text eg 'Continued on next page ...) only if the
document goes to page 2 and beyond. I can't do it with a macro prompt
button because in the template there is only one page. I'm not
experience enough to write code such as "if doc pages are more than 1
then .... etc etc. Can anyone help?

thanks
 
J

Jacqui

I have a document template which may or may not be two or more pages
long but in some case only 1. What I want to do is create a macro
that will show text eg 'Continued on next page ...) only if the
document goes to page 2 and beyond. I can't do it with a macro prompt
button because in the template there is only one page. I'm not
experience enough to write code such as "if doc pages are more than 1
then .... etc etc. Can anyone help?

thanks

I should have said - I already have the macro to find the bookmark on
page 1 then add the text, my problem is how to start this running when
the doc goes to page 2. Hope this makes sense.
 
G

Graham Mayor

You don't need a macro for this, you need a conditional field in the first
page footer of the document:

{IF {NUMPAGES} > 1 "Continued on next page ..." }

or if you have a running footer you could conditionally put it on the first
page only

{IF { PAGE } = 1 "{IF {NUMPAGES} > 1 "Continued on next page ..." }"}

If the document may run to more than two pages, you would need a variation

{ IF { PAGE } < { NUMPAGES } "{ IF { NUMPAGES } > 1 "Continued on next page
...." }" }

so that it doesn't print on the last page

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jacqui

You don't need a macro for this, you need a conditional field in the first
page footer of the document:

{IF {NUMPAGES} > 1 "Continued on next page ..." }

or if you have a running footer you could conditionally put it on the first
page only

{IF { PAGE } = 1 "{IF {NUMPAGES} > 1 "Continued on next page ..." }"}

If the document may run to more than two pages, you would need a variation

{ IF { PAGE } < { NUMPAGES } "{ IF { NUMPAGES } > 1 "Continued on next page
..." }" }

so that it doesn't print on the last page

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>





- Show quoted text -

This is fantastic Graham - thanks for your help. However...... It's
not working - when I put the field in the first page footer, the test
{PAGENUM} shows whether it's 1 page or not, and nothing happens when I
add a new page. I'm obviously missing something simple!
 
G

Graham Mayor

There is no PAGENUM field! It is either PAGE (the current page number) or
NUMPAGES (the total number of pages in the document). My guess is that this
was a typo and that you have not used CTRL+F9 for the curly brackets {} that
surround each field.

I think on reflection I would use my third example as it works for all
likely circumstances and you don't need to set a separate first page
footer..
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jacqui

There is no PAGENUM field! It is either PAGE (the current page number) or
NUMPAGES (the total number of pages in the document). My guess is that this
was a typo and that you have not used CTRL+F9 for the curly brackets {} that
surround each field.

I think on reflection I would use my third example as it works for all
likely circumstances and you don't need to set a separate first page
footer..
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>





- Show quoted text -

Sorry - I did make a typo but it was in my reply to you, I didn't put
that in my code. Here's the code I'm using (updated to your third
suggestion:

{IF {PAGE} < {NUMPAGES} "IF {NUMPAGES} > 1 "Continued over the
page...."}"}

This shows the text Continued on my footer (I want it to show nothing
if there is only one page) and when I create page 2 it still shows
this text. I must be missing somthing!
 
G

Graham Mayor

Sorry - I did make a typo but it was in my reply to you, I didn't put
that in my code. Here's the code I'm using (updated to your third
suggestion:

{IF {PAGE} < {NUMPAGES} "IF {NUMPAGES} > 1 "Continued over the
page...."}"}

This shows the text Continued on my footer (I want it to show nothing
if there is only one page) and when I create page 2 it still shows
this text. I must be missing somthing!

You are a bracket short

{ IF { PAGE } < { NUMPAGES } "{ IF { NUMPAGES } > 1 "Continued over the
page...." }" }

If that too was a typo and your document contains only one page, then
nothing should appear in the footer. Nor should it appear in the footer of
the last page.

If you have tested this by inserting text to spill over to the second page
then removed the text leaving the entry on the first page. Switch to print
preview and back to update the field.

It should update automatically as the text spills over to the second page.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jacqui

You are a bracket short

{ IF { PAGE } < { NUMPAGES } "{ IF { NUMPAGES } > 1 "Continued over the
page...." }" }

If that too was a typo and your document contains only one page, then
nothing should appear in the footer. Nor should it appear in the footer of
the last page.

If you have tested this by inserting text to spill over to the second page
then removed the text leaving the entry on the first page. Switch to print
preview and back to update the field.

It should update automatically as the text spills over to the second page.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

I added the bracket and now I get this .... help
Error! Missing second part of test condition.
 
E

Edward Thrashcort

I guess you are just typing-in the braces {} rather than inserting fields
into the formula

You have mail <<Example to show calculated footer.doc>>

Eddie
 
G

Graham Mayor

As Edward posted after I had packed up for the night, you cannot simply type
in the brackets. Each pair signifies a field and field boundaries are
inserted (as I said earlier in the thread) with CTRL+F9. No doubt you have
received Edward's document and copied the field to yours, but as you posted
your e-mail address in a public forum it will not be long before you are
inundated with spam. You may find yourself needing something like
http://www.gmayor.com/use_google_gmail_to_remove_spam.htm before long ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
R

Russ

Jacqui,
Yes, don't leave your real or unadulterated email address on the web.
Doing a google search for 'mung email hide' gives information like this
site:
<http://www.by-users.co.uk/archive/faqs/email/spam/>

I set up a NOSPAM pop account in my email client to reply to newsgroups. The
outgoing SMTP server address was the only 'real' thing in that account setup
to send replies. I left the incoming mail information part empty because I
'subscribe' to newsgroups to messages through another newsgroup function of
the email client. It was told to use my special NOSPAM signature as well.

To those who have made it this far, you may have noticed that I use angle
brackets around my links. What's up with that? :)
<http://blog.entourage.mvps.org/2007/07/insert_urls_into_a_message.html>
I use to use snipurl or cuturl or tinyurl because I was worried about broken
long links. The angle brackets seem to be working.
 
R

Russ

Sorry, for my bad grammar. "use to" should be "used to" and I should try to
avoid that phrase anyway.
 
J

Jacqui

As Edward posted after I had packed up for the night, you cannot simply type
in the brackets. Each pair signifies a field and field boundaries are
inserted (as I said earlier in the thread) with CTRL+F9. No doubt you have
received Edward's document and copied the field to yours, but as you posted
your e-mail address in a public forum it will not be long before you are
inundated with spam. You may find yourself needing something likehttp://www.gmayor.com/use_google_gmail_to_remove_spam.htmbefore long ;)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>





- Show quoted text -

Thanks for all your help Graham. Your code had an extra quotation
mark (before the second {IF ..which seemed to be the problem. FYI I
didn't type the brackets etc. I've learned loads here though, so
thanks.

Just need to figure out how to post to this group without showing my e-
mail address.... Thanks again
 

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