Printing using wdPrintRangeofPages not working w/ converter

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
Posts: 3
Joined: Wed Aug 03 2005

Printing using wdPrintRangeofPages not working w/ converter

Post by JackWooten » Wed Aug 03 2005

I am currently trying to automate the printing of a word doc that is 91 pages long. The .doc has a bookmark ("Print") defined to show the print range. As you can see below, I am finding the value of the bookmark and passing it to the .PrintOut call. In debug I can see that the value is "45". Thus, I would expect to receive a .PDF file with 45 pages. Unfortunately I still get the full 91 pages...

Any thoughts?

Code: Select all

Dim PDF As CDIntfEx.CDIntfEx = New CDIntfEx.CDIntfEx
            Dim origPath As String = txtOrigPath.Text
            Dim newPath As String = txtNewPath.Text

            Dim wa As Word.Application
            Dim wd As Word.Document 

            wa = New Word.Application 
            If File.Exists(origPath) Then
                PDF.DriverInit("Amyuni PDF Converter")
                PDF.EnablePrinter(companyName.ToString(), activationCode.ToString())
                wa.ActivePrinter = "Amyuni PDF Converter"
                wa.Visible = True
                wd = wa.Documents.Open(origPath)
                UpdateTxtBox("Document does not exist.")
            End If

            If File.Exists(newPath) Then
            End If

            Dim pages As String
            pages = wd.Bookmarks.Item("Print").Range.ComputeStatistics(WdStatistic.wdStatisticPages)
            wd.PrintOut(background:=True, range:=Word.WdPrintOutRange.wdPrintRangeOfPages, outputfilename:=newPath, pages:="1-45")

            wa = Nothing

Thanks ahead of time... any help is much appreciated.

Jack Wooten
Application Developer

Posts: 3
Joined: Wed Aug 03 2005

Re: Printing using wdPrintRangeofPages not working w/ conver

Post by JackWooten » Wed Aug 03 2005

JackWooten wrote: wd.PrintOut(background:=True, range:=Word.WdPrintOutRange.wdPrintRangeOfPages, outputfilename:=newPath, pages:="1-45")
Should actually read:

Code: Select all

            wd.PrintOut(background:=True, range:=Word.WdPrintOutRange.wdPrintRangeOfPages, outputfilename:=newPath, pages:="1-" & pages.ToString())
Sorry for the confusion.

Jack Wooten

Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002

Post by Joan » Thu Aug 04 2005


I tried to print out a range of pages from Access to the PDF printer and it worked fine. I have Word 2003.

I used pages := '1-2' and I got the first two pages of the document printed.

Please check if 'Pages' is computed properly in your code. If you replace Pages by 45, wont you get the first 45 pages printed?

I guess you are facing the same issue if you print to a physical printer because this issue is related to the Printout function of Word and not to the printer to which you are printing.

Hope this helpsl

Posts: 3
Joined: Wed Aug 03 2005

Post by JackWooten » Thu Aug 04 2005


Thank you for the reply. After some more investigation, the problem seems to be in the document itself. I can create another doc and get the proper action.

Thank you again.

Jack Wooten

Post Reply