Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2012, 02:35 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Exclamation Macro to insert new page...

please help!



For printing reasons, I need my word documents to

1) check the number of pages
2) if the number of pages is a multiple of 4, insert a blank sheet at the end of the document.

Is this possible?

Thanks in advance.
Reply With Quote
  #2  
Old 01-11-2012, 08:55 AM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Samantha,

You don't need a macro. You can use a formula field coded as:
{IF{=MOD({PAGE},4)}= 0 {QUOTE 12}}
Simply place the field before the final paragraph mark on the document's last page

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-18-2012, 08:14 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

Fantastic - thank you so much.

I'm having a problem though - I do not know how to insert a formula field.

I'm trying through INSERT>FIELD then copying the fomula under the IF section (Deleting the IF from there first, and deleting the {} from the edge of the code.

I can't just get it to work.

Any advice? Thanks
Reply With Quote
  #4  
Old 01-19-2012, 03:33 AM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Smantha,

As noted in my previous post:
Quote:
The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9
Inserting compound fields via the Insert|Field function is faiirly convoluted, partly for the reason that you can paste into that dialogue box the interior fields.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-19-2012, 04:37 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

Apologies - I didn't explain very well.

I have tried using ctrl+F9 in the insert field box. This does not work.

So I have done it straight into the document. I have tried every combination of Making the outside {}first, then doing ctrl+f9 for the inside {} as well. Deleting the spaces, etc.

I get the error (Upon right click and 'update field')

Error! Unkown op code for conditional.

I have never worked with fields before I'm afraid, but I am using ctrl+f9 for the {} as specified.

I am so happy to know this can be done, but am just struggling to get there

Last edited by samanthaj; 01-19-2012 at 04:40 AM. Reason: (my own stupidity)
Reply With Quote
  #6  
Old 01-19-2012, 03:03 PM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Smantha,

The Ctrl-F9 is done in the document, not in the Insert|Fields dialogue box.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 01-20-2012, 12:20 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

That is what I have been doing.

I am still getting the above error though.
Reply With Quote
  #8  
Old 01-20-2012, 02:26 AM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Smantha,

See the attached. The document presently has only one page. Pressing Alt-F9 toggles the field code display on/off.
Attached Files
File Type: doc PageBreakDemo.doc (29.5 KB, 15 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 01-20-2012, 02:41 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

Ok - that is great.

I think, therefore, that my problem lies in the working of fields.

How do I make it 'work'?

For example - if my document has 8 pages - how does this field code add in the extra page? Because currently nothing happens. I know I'm missing something very obvious and I really appreciate your time in helping me.
Reply With Quote
  #10  
Old 01-20-2012, 03:26 AM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Samantha,

To make the field 'work', there's only two things you'll need to do:
• Place the field before the final paragraph mark on the document's last page; and
• Make sure Word's 'update fields' option is checked under Tools|Options|Print.
If, at print time, your document a multiple of four pages (per your specs), the field will insert a page break and, hence, start a new page at that point. Conversely, the field will delete that break if these conditions aren't met.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 01-20-2012, 06:58 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

It works!! Thank you so much! I hadn't got update in tools selected.

Each of my documents will have a different number of pages. For documents of either 7 or 11 pages - I need to insert 2 pages. I've tried playing around with the coding (QUOTE 12 is page break I think?) but can't quite get there.

Can you have multiple conditions within one code?
Reply With Quote
  #12  
Old 01-21-2012, 11:00 PM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Samantha,

If I understand your requirements correctly, you need something like:
{IF{=MOD({PAGE},4)}= 2 {QUOTE 12 12 12} {IF{=MOD({PAGE},4)}= 3 {QUOTE 12 12} {IF{=MOD({PAGE},4)}= 0 {QUOTE 12}}}}
See attached.
Attached Files
File Type: doc PageBreakDemo.doc (25.5 KB, 13 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 01-27-2012, 02:24 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

Thank you so much - that works beautifully macropod.

I have hit another problem though. The program I am merging from is set up with 40 pages originally. When I merge, it only merges the relevant pages for each case - usually between 8 - 14 but some anomalies.

The program doesn't even look at the pages it is not going to merge.

So of course, when I paste this code at the end of the document, unless the last page is included in the merge, it is completely ignored.

I have thought of a couple of possibilities. Could this be placed in the footer? But if it is, will it be read and acted upon on every page, or just the last page?

My other thought is to add another page at the end of the document - something generic - for example the company logo for the back page of the document which would be then merged in every instance. This solves the problem of the code not being merged, but it means the pages would need to be inserted before that final page, rather than after. And from what I see QUOTE 12 is to insert a page break - so is there an equivalent QUOTE which will do the opposite? (I have a feeling not?)

I really do apperciate all the time you have put in to helping me macropod - I really don't know where we'd be without your help!
Reply With Quote
  #14  
Old 01-27-2012, 03:05 AM
macropod's Avatar
macropod macropod is offline Macro to insert new page... Windows 7 64bit Macro to insert new page... Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Samantha,

This the first mention you've made of merging. Is this a mailmerge, or something else? Since a document always has a last page, whatever you're adding to the document needs to be on or before that page - and always before the field code. Some more detail about the process wouldn't go astray ...

And no, there isn't a field code for removing an existing page break.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 01-27-2012, 03:14 AM
samanthaj samanthaj is offline Macro to insert new page... Windows XP Macro to insert new page... Office 2003
Novice
Macro to insert new page...
 
Join Date: Jan 2012
Posts: 9
samanthaj is on a distinguished road
Default

I'm sorry - I was rather vague wasn't I?!

It is for student reports. The system is set up for every eventuality of reports and subjects. Of course not all students study each subject. So the merge only merges the relevant subjects for each student. The subjects are alphabetically arranged - one page per subject. So not every student studies World Politics (the last subject in order), so it is not merged for every report. So if I put the coding at the bottom of that page - the merge will completely ignore the page.

Considering the above, the last page is always present - but it varies between reports. So I cannot place it in a place which will be consistant. Of course I could move a generic report to the back, for example mathematics, which all students study, but it would be unusual to have a principal subject at the end and my managers are keen to avoid that.

It is a mail merge, but not from a microsoft product.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Insert Text Into Cells Having Multiple Lines revans611 Excel Programming 4 10-24-2011 10:15 AM
VBA: Recording a macro to insert a PIVOT table e093223 Excel Programming 0 10-09-2011 01:55 AM
Powerpoint Macro To Insert Objects Sample lahuva PowerPoint 0 07-06-2011 10:51 AM
Insert Page Error nmbrown Word 1 10-28-2010 10:33 AM
Macro to insert new page... Macro for Picture Insert rfhall50 Word VBA 2 10-25-2010 12:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft