Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 01-27-2012, 10:11 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,963
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,

When you say "It is a mail merge, but not from a microsoft product", does Word do the mailmerge, or are you just getting a document generated by your application that Word can open? It makes a huge difference.



Assuming Word is doing the mailmerge, you're probably using either a letter merge or a Directory/Catalog merge.

With a letter mailmerge, what ordinarily happens is that you get a document with one page per record, with 'Next Page' Section breaks separating the pages. To list all the records for each student sequentially, they'd need to be sorted or a sort applied as part of the mailmerge process. A Directory/Catalog merge, on the other hand, can output page breaks between the records. In either case, if you want to insert a number of blank pages between the sets of records for each student, there are two problems that have to be addressed:
1. Identifying when the students change (eg different student IDs); and
2. Calculating how many blank pages to insert. With a mailmerge, you can't do that using IF fields at all, since IF fields get converted to their results at the time of the merge - which is liable to mean either no output or the same potentially wrong output from them at all. Furthermore, if you're using a letter merge, the page count returned by the field code will typically be '1', since whatever Section the field is in is liable to have only 1 page ...
I know how to deal with both issues, but I'd need to know just how your merge is being done before getting into those issues.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #17  
Old 01-31-2012, 07: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
Default

The file is generated through the program and opened in Word. Although, I believe it to be an .xml file, not .doc.

Thanks again macropod - we really appreciate your help, advice and time.
Reply With Quote
  #18  
Old 01-31-2012, 01:53 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,963
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,

OK, maybe trying to build the logic into the documents themselves isn't going to work. Here's a macro you can try instead. Add it to Word's 'Normal' template and it'll be available to run on any document.
Code:
Sub Mod4Pages()
With ActiveDocument
  While .Range.ComputeStatistics(wdStatisticPages) Mod 4 <> 0
    .Range.InsertAfter Chr(12)
  Wend
End With
End Sub
Now, once your document has been generated, simply run the macro against it and however many page breaks are required will be inserted to bring the total up to a multiple of 4.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



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 08:21 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