Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 19th, 2003, 07:02 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default printing word document

Hi All,
I have a word template and i am filling it with some data from vbscript code.which will run into number of pages.
i have a last page the contents of which will be filled in by onother document(ex. objPo.selection.insertfile "file name")

everything is fine till now.

I want to print the last page after each page of the template.

can anybody give me a vb code snippet.

it should print like this

Ist page ,last page,II nd page ,last page ,..... last but one page,lastpage
please note that the printout should also include the proper page numbers(ex page 1 of 5)

Thanks in advance

Vadiraj

Reply With Quote
  #2 (permalink)  
Old December 11th, 2003, 06:38 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not that familiar with Word VBA, but my suggestion is to create a macro which loops through all pages of the first document, printing that particular page followed by the 'last page'. Something like this:

Code:
Sub PrintMyDocument()
 'Initialize
 Dim FirstDoc As Object
 Dim SecondDoc As Object
 FirstDoc = Documents("FirstDocument.doc") 'File which contains all pages
 SecondDoc = Documents("SecondDocument.doc") 'File which contains the 'last page'
 
 'Get the number of pages
  PageCount = FirstDoc.BuiltInDocumentProperties(wdPropertyPages)
  
 'Loop through the pages
 For n = 1 To PageCount
     'Print a page from the first document
     FirstDoc.PrintOut Range:=wdPrintRangeOfPages, Item:=wdPrintDocumentContent, _
        Copies:=1, Pages:=Trim(Str(n)), PageType:=wdPrintAllPages, ManualDuplexPrint:=False, _
        Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
        PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
     'Print the 'last page' (page 1 of the second page)
     FirstDoc.PrintOut Range:=wdPrintRangeOfPages, Item:=wdPrintDocumentContent, _
        Copies:=1, Pages:="1", PageType:=wdPrintAllPages, ManualDuplexPrint:=False, _
        Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
        PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
 Next
 
End Sub
Please note that I didn't test it nor do I give any warranty.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing document using c# shahanaz C# 0 October 4th, 2007 08:29 AM
Printing & Setting the margin of document... ravi_bachwala General .NET 1 August 9th, 2007 06:54 PM
Ch 7, p234-239: Printing a Document mk goody BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 0 July 17th, 2007 09:30 PM
Printing an html document amc Dreamweaver (all versions) 1 May 31st, 2004 11:42 AM
Problem in printing Document in JS... sweetee JSP Basics 0 May 22nd, 2004 01:10 AM



All times are GMT -4. The time now is 11:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.