Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Mail merge crashing with many records
Message
From
11/08/2009 15:05:41
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2000 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01417134
Message ID:
01417385
Views:
44
Goes about like this:
THIS.OpenMailMerge ()    && Open the main document and set the datasource

*-- Set the page options
WITH THIS.oWord.ActiveDocument.PageSetup    && THIS.oWord point to the instance of Word
    .Orientation = 0	&& wdOrientPortrait
    .TopMargin = THIS.oWord.CentimetersToPoints (2.5)
    .BottomMargin = THIS.oWord.CentimetersToPoints (2.5)
    .LeftMargin = THIS.oWord.CentimetersToPoints (2.5)
    .RightMargin = THIS.oWord.CentimetersToPoints (2.5)
    .Gutter = THIS.oWord.CentimetersToPoints (0)
    .HeaderDistance = THIS.oWord.CentimetersToPoints (0)
    .FooterDistance = THIS.oWord.CentimetersToPoints (0)
    .PageWidth = THIS.oWord.CentimetersToPoints (21.59)
    .PageHeight = THIS.oWord.CentimetersToPoints (27.94)
    .OtherPagesTray = 0	&& wdPrinterDefaultBin
    .SectionStart = 2	&& wdSectionNewPage
    .OddAndEvenPagesHeaderFooter = .T.
    .DifferentFirstPageHeaderFooter = .F.
    .VerticalAlignment = 0	&& wdAlignVerticalTop
    .SuppressEndnotes = .F.
    .MirrorMargins = .F.
    THIS.SetTray (THIS.nBac, THIS.oWord.ActiveDocument.PageSetup)    && Set the paper tray
    .OddAndEvenPagesHeaderFooter = .F.
    .TwoPagesOnOne = .F.
    .BookFoldPrinting = .F.
    .BookFoldRevPrinting = .F.
    .BookFoldPrintingSheets = 1
    .GutterPos = 0	&& wdGutterPosLeft
ENDWITH

*-- Run the mailmerge
WITH .oWord.ActiveDocument.MailMerge
    .Destination = 0    && New document
    .DataSource.FirstRecord = 1
    .DataSource.LastRecord = RECCOUNT (m.lcData)    && Total number of records of the datasource
    .SuppressBlankLines = .T.
    .Execute ()    && Run the mailmerge
ENDWITH
					
THIS.oWord.Documents(THIS.cMMDocument).Close (0)    && Close the main document

*-- Print each page separatly (this goes inside a loop)
WITH THIS.oWord
    .Activedocument.Sections(m.tnPageNo).Range.Select ()    && Select the page to print
    .Selection.End = .Selection.End - 1    && Remove the end of page marker from the selection
    .ActiveDocument.PrintOut (0, , 1)    && Print the page    <-- THIS IS THE COMMAND THAT SEND WORD IN THE NO MAN LAND
ENDWITH
>Could you please, post your code for merging and printing (or gave me the link to it)?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform