Reputation: 121
I would like to print an image that shows in a frame on a userform.
frame1.Picture = LoadPicture(spath & xPicture & ".jpg")
spath
is the full path to where the picture is stored.
This shows the picture.
I would like to print it.
Is there code to do this from a userform or is there code to print it from the file location?
Upvotes: 2
Views: 5362
Reputation: 31374
One option is to call Windows Print dialog via shell command.
Example: (Full code)
Option Explicit
Private 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
Private Sub CommandButton1_Click()
Dim MyPicFile As String: MyPicFile = "C:\Users\PortlandRunner\Pictures\excel.jpg"
Call apiShellExecute(Application.hwnd, "print", MyPicFile, vbNullString, vbNullString, 0)
End Sub
Private Sub UserForm_Initialize()
Dim spath As String
spath = "C:\Users\PortlandRunner\Pictures\excel.jpg"
Image1.Picture = LoadPicture(spath)
End Sub
Form:
Clicking button opens Windows Office print dialog:
Upvotes: 1