Solved

copying plot files

Posted on 1998-01-12
3
460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

734 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