View Single Post
  #1 (permalink)  
Old February 12th, 2005, 04:24 PM
bml bml is offline
Registered User
 
Join Date: Feb 2005
Location: , , Canada.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default shell function problem

I've created a routine create a batch file that will merge some print files and then send the single file to the application.activePrinter

I need to do this to avoid having a banner page printing between every print (I have no option to turn off the banner page on a network printer)

The batch file created from the code runs fine if I run it manually but if I use the shell function, nothing happens.

A portion of the code is listed below:

        For i = 0 To cntrl.ListCount - 1
            .PivotFields(sField).CurrentPage = cntrl.Column(0, i)
            sTemp = "F" & Format(i, "0000") & ".prt"
            Sheets(sSheet).PrintOut PrintToFile:=True, _
                    PrToFileName:=Range("PrtPath") & "\" & sTemp
            If i = 0 Then
                file.write "copy/b " & sTemp & " merge.prt" & vbCrLf
            Else
                file.write "copy/b merge.prt + " & sTemp & vbCrLf
            End If
        Next i

    End With
    sTemp = Application.ActivePrinter
    sTemp = Mid(sTemp, 1, InStr(1, sTemp, " ") - 1)

    file.write "copy/b merge.prt " & sTemp & vbCrLf
    file.write "del *.prt" & vbCrLf
    file.write "del " & sBatchFile & vbCrLf
    file.Close


    If Shell(sBatchFile, vbNormalFocus) = 0 Then MsgBox "Shell'd print batch was not successful"
Reply With Quote