Solved

Printing to a file and set the filename automatic...

Posted on 2002-04-24
20
227 Views
Last Modified: 2008-02-01
Hello experts,

I have a problem,

I have a apllication and it makes 250 different printjobs
i have to print them one at a time i don't want to change this (cannot change for several reasons..)

but when i print the jobs to the printer driver that makes a .ps file of it... i have to fill in the filename 250 times!!
so i want to print to a .ps file thru the printer driver but i want it to generate the filenames itself so i don't have to do it....

Please HELP me... !

Thanks in advance

greetings,

Floris van Haaster
The Netherlands
0
Comment
Question by:baco
20 Comments
 
LVL 3

Expert Comment

by:n_narayanan
Comment Utility
which operating system you are using and what commands you are using. Can you explain in detail.

Narayanan
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
If you are using Word application to start the printing, then you can use one of the print method parameters.

If it's some other dll or 3rd party, you will shurely have some option that will solve it, we might be able to help when you identify how you are printing...

CHeers
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
Hi Floris,

....don't know what you're using here but is there no batch processing in the printing process?

i use ghostscript to generate PS charts and in the batch settings it will use the filename of the file to process as the filename of the output file

As Narayanan asked a bit more detail should help are you using VB to send this to the printer or something?

:O)Bruintje
0
 
LVL 3

Expert Comment

by:Rem
Comment Utility
ping

Yep details please

tot horens

Rem
0
 

Author Comment

by:baco
Comment Utility
I use the Adobe Acrobat reference and i close a batch like this:

Private Sub EndBatch()
    AcroDoc.PrintPages 0, PdDoc.GetNumPages, 2, False, False
    Total_Pages = Total_Pages + PdDoc.GetNumPages
    PdDoc.ClearFlags (PDDocNeedsSave)
    AcroDoc.Close (False)
End Sub

so acrodoc.printpages prints the batch to the printerdriver but i can't give it a filename....
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
well i steal a bit of code once written by Karl De Abrew from www.roundtable.com.au


Option Explicit ' Force variable declaration
' Author : Karl De Abrew
' Company : Round Table Solutions
' Date : 08 March 1998
' Description: PrintAllAcrobatDocsInDir
' This vb method uses IAC to print all documents in a
' directory.
' This method / function should be extended to suit the requirements
' of an organisation

Public Const POSTSCRIPT_LEVEL = 2
Public Const PDF_WILDCARD = "*.pdf"
Public Const PDF_DIRECTORY = "c:\acrobatdocstoprint\"

Sub PrintAllAcrobatDocsInDir()
Dim AcroExchAVDoc As Object, AcroExchPDDoc As Object, _
AcroExchApp As Object
Dim strFileName As String, strPath As String
Dim iNumberOfPages As Integer

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

' Show the Acrobat Exchange window
AcroExchApp.Show
' Set the directory / folder to use
strPath = PDF_DIRECTORY
' Get the first pdf file in the directory
strFileName = Dir(strPath + PDF_WILDCARD, vbNormal)
' Start the loop.
Do While strFileName <> ""

' Open the [strFileName] pdf file
AcroExchAVDoc.Open strPath + strFileName, ""
' Get the PDDoc associated with the open AVDoc
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc
' Get the number of pages for this pdf [and subtract one as zero based]
iNumberOfPages = AcroExchPDDoc.GetNumPages - 1
' Print all pages in this document
AcroExchAVDoc.PrintPages 0, iNumberOfPages, POSTSCRIPT_LEVEL, True, False
' Close this file
AcroExchAVDoc.Close True
' Get the name of the next file in the directory
strFileName = Dir
Loop

' Close Acrobat Exchange
AcroExchApp.Exit
End Sub


And i guess you can apply certain elements, to open the files ready to PS through adobe you can loop the function through the directory where these files are instead of filling the name by hand

HTH:O)Bruintje
0
 

Author Comment

by:baco
Comment Utility
No i can't use this because when i use this app i still have to fill in a filename when i print to file....

sorry thanks anyway!

...

..

.....
still no solution....
...
...
.
.
.....
....

...
0
 

Author Comment

by:baco
Comment Utility
No i can't use this because when i use this app i still have to fill in a filename when i print to file....

sorry thanks anyway!

...

..

.....
still no solution....
...
...
.
.
.....
....

...
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
>>>so acrodoc.printpages prints the batch to the printerdriver but i can't give it a filename

so the Acrobat object just comes up with the box? out of your control? which Acrobat object is this do you have to set it somewhere in your code like

set acrodoc = new "something here"
or
set acrodoc = createobject("something here")

can you get the referenced dll you use?

i just wonder if there is no property for the filename in adecent objectmodel

:O)Bruintje
0
 

Author Comment

by:baco
Comment Utility
YES!!!!!!!!!!!! i got it!!!

    PdDoc.Save 1, "c:\batch" & batch_number & ".pdf"

cool!! but ....
who earns the points??
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:baco
Comment Utility
i forgot...

like this it will save a pdf file.. then i will convert it to ps and then it's done!
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
hmmmm.......seems to me you solved it yourself so ask a 0-point Q in CS and make this a PAQ because there is value in it

:O)Bruintje
0
 

Author Comment

by:baco
Comment Utility
and how will i do that?
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
OK,

Go here
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

ask a new Q
-Ask a moderator to refund your points for this Q
-Ask them to make this a PAQ

:O)Bruintje
0
 

Author Comment

by:baco
Comment Utility
:)

I found out that you can allso add a new printer in windows
and make a new port for the printer so don't send it to lpt1 or something like that.. but something like :

c:\postscript.ps

this really works!
0
 
LVL 44

Accepted Solution

by:
bruintje earned 500 total points
Comment Utility
you just print to file then through the postscript printer driver, that's nice
0
 

Author Comment

by:baco
Comment Utility
Yes then I check if the file is in use...if it's not (then the printing to file is done)
then i can move it to another location with the new filename i want and continue with the next print job :)

Greetings,

Floris
0
 

Author Comment

by:baco
Comment Utility
Bruintje,

ik paas mijn punten wel door aan jou je hebt goed geprobeert mij te helpen in ieder geval :)

Bedankt!
0
 

Author Comment

by:baco
Comment Utility
Thanks again!
0
 
LVL 44

Expert Comment

by:bruintje
Comment Utility
bedankt, je had ze ook voor een volgende vraag kunnen bewaren

thanks again
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now