Solved

copying plot files

Posted on 1998-01-12
3
454 Views
Last Modified: 2008-03-10
I've asked this question quite a few times - but no answer works.

I use AutoCAD to create plot files which I send either to a laser printer or to a HP inkjet plotter and these are mapped to different ports or print queues through Novell 3.12.

I store in a separate file a list of the plot files together with a number referring to how it was printed.

I want to be able to automatically send the plot file to the correct printer, but so far no solution works.

I've tried

Shell Environ$("comspec") & " /c copy /b " & c$ & " LPT" & FnStr$(i&) & ":"

which returns
This program is set to run in MS-DOS mode and cannot run while other programs are running. All other programs will close if you choose to continue.

and

f& = FreeFile
Open c$ For Input As f&
r$ = Input$(LOF(f&),f&) & vbFormFeed
Close f&
i& = OpenPrinter(p$, j&, 0)
If i& = 0 Then MsgBox "unable to open " & p$ & "!", vbOKOnly + vbExclamation + vbSystemModal: Exit Function
With doc
      .pDocName = a$
      .pOutputFile = vbNullString
      .pDataType = vbNullString
End With
i& = StartDocPrinter(j&, 1, doc)
StartPagePrinter j&
WritePrinter j&, r$, Len(r$), k&
EndPagePrinter j&
EndDocPrinter j&
ClosePrinter j&

any ideas?

0
Comment
Question by:broadbent
  • 2
3 Comments
 
LVL 8

Expert Comment

by:mrmick
ID: 1450636
broadbent, what is the error returned by the second method (the API method)?
0
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
ID: 1450637
Instead of r$, use a byte array as your buffer.  For example, populate the buffer as follows:

Dim PrintBuf() As Byte, BLen As Long
Open c$ For Binary Access Read As f&
BLen = LOF(f&) + Len(vbFormFeed)
ReDim PrintBuf(BLen)
For i& = 0 To LOF(f&) - 1
 Get #f&, , PrintBuf(i)
Next
PrintBuf(BLen - 1) = vbFormFeed

Change the WritePrinter statement to:

WritePrinter j&, PrintBuf(0), BLen, k&

This means the declaration for WritePrinter would have to be either:
Declare Function WritePrinter Lib "winspool.drv" Alias "WritePrinter" (ByVal hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long) As Long

OR

Declare Function WritePrinter Lib "winspool.drv" Alias "WritePrinter" (ByVal hPrinter As Long, pBuf As Byte, ByVal cdBuf As Long, pcWritten As Long) As Long

0
 
LVL 4

Author Comment

by:broadbent
ID: 1450638
The original problem was that nothing happened

BUT this works except that line should be
         PrintBuf(Blen-1)= Asc(vbFormFeed)

I've learnt something - many thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 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

15 Experts available now in Live!

Get 1:1 Help Now