Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2003, 07:02 AM
Registered User
 
Join Date: Sep 2003
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

 
Old December 11th, 2003, 06:38 AM
Registered User
 
Join Date: Dec 2003
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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.