How to print an image file directly

%3CLINGO-SUB%20id%3D%22lingo-sub-2947270%22%20slang%3D%22en-US%22%3EHow%20to%20print%20an%20image%20file%20directly%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2947270%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20Morning%3CBR%20%2F%3EI%20wanted%20to%20ask%20two%20things%3A%3CBR%20%2F%3E1st%20-%20With%20excel%2C%20I%20need%20to%20open%20a%20JPG%20file%20that%20is%20on%20my%20disk%20and%20print%20that%20file%20directly%2C%20without%20opening%20any%20external%20program%20or%20window%20asking%20the%20user%20to%20ask%20questions.%3CBR%20%2F%3EIf%20excel%20has%20to%20open%20some%20application%2C%20at%20least%20don't%20question%20the%20user%20and%20open%20and%20close%20the%20program%20automatically.%3C%2FP%3E%3CP%3E2nd%20-%20When%20printing%20the%20image%20file%2C%20(which%20is%20a%20photo%20of%20a%20document%20in%20A4)%2C%20it%20is%20possible%20to%20place%20a%20footer%20text%20on%20the%20same%20page%20as%20the%20image%3CBR%20%2F%3E%3F%3CBR%20%2F%3EIs%20it%20possible%20to%20do%20this%20procedure%3F%20How%20can%20I%20do%20it%3F%3CBR%20%2F%3EThank%20you%20for%20your%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2947270%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

Good Morning
I wanted to ask two things:
1st - With excel, I need to open a JPG file that is on my disk and print that file directly, without opening any external program or window asking the user to ask questions.
If excel has to open some application, at least don't question the user and open and close the program automatically.

2nd - When printing the image file, (which is a photo of a document in A4), it is possible to place a footer text on the same page as the image
?
Is it possible to do this procedure? How can I do it?
Thank you for your help.

1 Reply

Good afternoon
From the research I've been doing, I've already realized that what I want can't be achieved with Excel, without having to program the printing manually, which I'm not able to do.
I found this code that was supposed to open the file and the windows window, to print, but I can't make the window open. O que estarei a fazer errado?

It's not the ideal solution, because there are a lot of files to print, but it's better than nothing.

Declare PtrSafe Function ShellExecute 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

Declare PtrSafe Function apiFindWindow Lib "User32" Alias "FindWindowA" _
() ' (ByVal lpclassname As Any, ByVal lpCaption As Any) As Long

Global Const SW_SHOWNORMAL = 1

Sub teste()
Dim hwnd
Dim StartDoc
hwnd = apiFindWindow("OPUSAPP", "0")

Dim mypath As String, myfile As String, strFilePath As String
mypath = "C:\Users\LRMud\TESTE\09 - TI'S - General\GESTAO DESPESAS\21PT00\Ana\"
myfile = Dir(mypath & "2021119_21PT00_Ana_2_01.jpg")
strFilePath = mypath & myfile
StartDoc = ShellExecute(hwnd, "Print", strFilePath, "", "", SW_SHOWNORMAL)
End Sub