Acc2K - Printing PRN Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MindBender77
    New Member
    • Jul 2007
    • 233

    Acc2K - Printing PRN Files

    Hello Again All,
    I've been trying to find a solution for this with repeated failure.
    The goal is to copy a PRN file to a network printer. I decided to use the Shell() command to accomplish this. The problem is that I can bring up the Dos command line but, the dos command is not executed. Am I just not understanding the usage of Shell() ?

    Here is my code so far:
    [code=vb]
    Private Sub cmd_invoice_Cli ck()
    Dim Pal_location As String
    Dim dos_command as String

    Pal_location = "X:\Stage\P RN Test Files\order_INV .prn"
    dos_command = "copy /c " & Pal_location & " \\server\printe r"

    Shell ("CMD.EXE " & dos_command & "")
    End Sub
    [/code]

    Any Help would be appreciated,
    Bender
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Why Shell Out to a DOS Environment at all?
    Code:
    Dim Pal_location As String
    Dim strDestination As String
     
    Pal_location = "X:\Stage\PRN Test Files\order_INV.prn"
    strDestination = "\\server\printer\order_INV.prn"
     
    FileCopy Pal_location, strDestination

    Comment

    • MindBender77
      New Member
      • Jul 2007
      • 233

      #3
      Originally posted by ADezii
      Why Shell Out to a DOS Environment at all?
      Code:
      Dim Pal_location As String
      Dim strDestination As String
       
      Pal_location = "X:\Stage\PRN Test Files\order_INV.prn"
      strDestination = "\\server\printer\order_INV.prn"
       
      FileCopy Pal_location, strDestination
      I'd forgotten about "FileCopy". This is much cleaner than using Shell.

      Thanks for the assistance, ADezii !

      Bender

      Comment

      • MindBender77
        New Member
        • Jul 2007
        • 233

        #4
        Originally posted by ADezii
        Why Shell Out to a DOS Environment at all?
        Its seems that FileCopy does not work when attempting to send a prn file to a network printer. I did find, however, a simple solution. I'll post it so it may help others.

        [code=vb]
        Private Sub cmd_invoice_Cli ck()
        Dim file_name As String
        Dim strDestination As String

        file_name = "X:\PRN Test Files\order_INV .prn"
        strDestination = "\\server\print er"

        Shell "cmd.exe /c copy " & file_name & " " & strDestination & ""
        End Sub
        [/code]
        Bender
        Last edited by MindBender77; Jul 1 '08, 08:00 PM. Reason: Solution

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32654

          #5
          Yes, you had the CMD.Exe /C switch AFTER the Copy parameter (essentially making it a COPY switch instead). /C & /K must come before the command and after the CMD.Exe.

          PS. This is a Windows question really, but as it's phrased as Access I will leave it here. The original question might throw a Windows member.

          Comment

          Working...