Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Mail merge using VBA stapling group of sections instead

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fernao H.C. Beenkens - 07 Mar 2008 12:49 GMT
Dear mr. Robbins,

With great interest I read your answer on a previous question, namely how to
print and staple individual sets within a mail merge document. Your answer
was related to the following VBA-code, which I used successfully;

Dim i As Long
With ActiveDocument
For i = 1 To .Sections.Count
.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i
End With

However... Only afterwards (after having used a test document) I saw that I
used several (13 in total) sections in my original main document, this
because of facts having to do with document mark-up.

Your solution works perfectly fine with a document created from the merge to
document function, which inserts a section break after each individual set.
However, do you know how I can change the code so that e.g. every 13 sections
are being stapled together (since the 14th section is being generated
automatically by the mail merge to single document function). Off course I
could also leave out my own section breaks, but this would completely mess up
the layout of my document.

I'm asking this with regard to a questionaire for my phd-research and would
be most grateful if you could provide me with some information!

Yours sincerely,
Fernao Beenkens
macropod - 10 Mar 2008 10:29 GMT
Hi Fernao,

Since each 'set' has 14 sections, you could change:

For i = 1 To .Sections.Count
.PrintOut Range:=wdPrintFromTo, From:="s" & i, To:="s" & i
Next i

to:

For i = 1 To INT(.Sections.Count / 14)
.PrintOut Range:=wdPrintFromTo, From:="s" & i * 14 + 1, To:="s" & (i + 1) * 14
Next i

Cheers
Signature

macropod
[MVP - Microsoft Word]
-------------------------

> Dear mr. Robbins,
>
[quoted text clipped - 26 lines]
> Yours sincerely,
> Fernao Beenkens
Doug Robbins - Word MVP - 10 Mar 2008 12:46 GMT
I think that should be:

For i = 0 To INT(.Sections.Count / 14) - 1
.PrintOut Range:=wdPrintFromTo, From:="s" & i * 14 + 1, To:="s" & (i + 1) *
14
Next i

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi Fernao,
>
[quoted text clipped - 51 lines]
>> Yours sincerely,
>> Fernao Beenkens
macropod - 10 Mar 2008 13:41 GMT
Ah, yes ... 0!

Cheers
Signature

macropod
[MVP - Microsoft Word]
-------------------------

>I think that should be:
>
[quoted text clipped - 58 lines]
>>> Yours sincerely,
>>> Fernao Beenkens
Fernao H.C. Beenkens - 10 Mar 2008 14:11 GMT
Guys,

You are amazing > Thank you V E R Y much :)!

all the best,
Fernao

> I think that should be:
>
[quoted text clipped - 58 lines]
> >> Yours sincerely,
> >> Fernao Beenkens

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.