I am trying to make a team macro in Excel:
1st Macro gets Folder Path by selecting location of folder.
Then in excel, there are lines, that fill in the file names (for example all PDF.'s that are in the folder)
2nd Macro is called Print Loop. It goes trough the array of file names, and sends them to the Printer to print.
Macro works, but only problem:
When printer prints, it mixes the sheets. It is a total chaos! Is it possible to send some feedback to macro from printer, or to make macro work so that it would keep the order of file named and printed files ?
I attach the Macro excel file. Everything is under "Print_Files" sheet
When printer prints, it mixes the sheets. It is a total chaos!
I did not look at your file. however, you mean that the ORDER of the printing is different than the order that you sent each sheet to the printer? if that is what you mean, it really doesn't make much sense to me. when you send docs to a print queue, they *should* be logged in order, and then when the printer is ready to execute, print in the order that they came into the queue in. can you take a screenshot of the actual print queue on your machine? on a win machine, it is under devices and printers in the CP. right click on the printer you are using and select "print queue".
Thank you for reply. I think there was something wrong with the code too. As the the sheet order that were combined in one PDF was also wrong. If you could take your time to look at the attached file?..
Maybe there is some sort of simple syntax to make printer print order check, of fixed?
I attach the Print Loop code here that I use:
PHP Code:
Declare PtrSafe Function apiShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As LongPtr, _
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)
Dim r As Range
Dim rCell As Range
For Each r In Range("B3", "B102")
If Not r.EntireRow.Hidden Then
For Each rCell In r.Cells
'Debug.Print r.Row
FileName = rCell.Value '1st number is row, 2nd is collumn (B)
FullFileName = PathName & FileName '& ".pdf"
PrintFile (FullFileName)
Next rCell
I have never used the shell execute dll file in Windows in any version of Windows for that matter. But it looks to me like you're doing everything correctly because you're looping through the cells and that should essentially throw every file into the queue in order that you specified and that you capture the file names for. So there shouldn't be any problem there. I really can't see anything wrong with any of the code you posted but I find it kind of comical that you actually used PHP tags instead of code tags here on the board. So kudos to you for finding the appropriate tags to color code work that you did lol.
I can't really offer any more help here because I've already said that it looks just fine. The only thing I would suggest to get this straightened out is to download the freeware called dll viewer. there are a few different freeware programs on the internet on various websites that serve the same purpose and if you open those programs you can select library files of any kind for the VBA language like ocx lib dll and olb files. And the dll viewer program will tell you everything that's in those files in human readable form and not the garbled junk you usually see if you open a dll in notepad. So the libraries that I just referenced stand for ActiveX files dll files object libraries and type libraries. and those are all related to the VBA language for office programs. that's about all I have to offer you so hopefully it does you some good sorry.
I have never tried to print a pdf file from excel but apparently there is others who do and have some hiccups also.
I was just going to show the code but would be stuck for an answer if one came.
So, unfortunately, if it does not give you what you need, I can't help you any further.
Good Luck though.
Bookmarks