Solved

copying plot files

Posted on 1998-01-12
3
453 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
Comment Utility
broadbent, what is the error returned by the second method (the API method)?
0
 
LVL 8

Accepted Solution

by:
mrmick earned 100 total points
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

17 Experts available now in Live!

Get 1:1 Help Now