Tim_Excel_
Well-known Member
- Joined
- Jul 12, 2016
- Messages
- 512
Hi forum,
I have a VBA code which prints out a bunch of files in a folder. The files are named with numbers, which are listed in a column in my sheet. It takes a very long time for the first file to be sent to the printer (~30 secs), and for each time the next time is printed I have to wait another 30 secs as well. This is very inconvenient, since large numbers of files have to be printed.
The code runs through all the cells in the column and dims their value as variable 'VR1'.
NB: the pc is not directly connected with the printer, but rather via a network.
Does anyone know why this is taking so long, and how this can be done faster?
Thanks in advance
I have a VBA code which prints out a bunch of files in a folder. The files are named with numbers, which are listed in a column in my sheet. It takes a very long time for the first file to be sent to the printer (~30 secs), and for each time the next time is printed I have to wait another 30 secs as well. This is very inconvenient, since large numbers of files have to be printed.
The code runs through all the cells in the column and dims their value as variable 'VR1'.
Code:
Declare Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
Public Sub PrintFile(ByVal strPathAndFilename As String)
Call apiShellExecute(Application.hwnd, "print", strPathAndFilename, vbNullString, vbNullString, 0)
End Sub
Sub Print()
........
PrintFile "" & sPath & "\TEMP_printen\" & VR1 & ".pdf" 'sPath is the desktop path of the user
End Sub
NB: the pc is not directly connected with the printer, but rather via a network.
Does anyone know why this is taking so long, and how this can be done faster?
Thanks in advance