如何打印图像?
How to print an image?
我想打印一张显示在用户表单框架中的图像。
frame1.Picture = LoadPicture(spath & xPicture & ".jpg")
spath
是图片存放的完整路径
这显示了图片。
我要打印出来
是否有从用户表单执行此操作的代码,或者是否有从文件位置打印它的代码?
一个选项是通过 shell 命令调用 Windows 打印对话框。
示例:(完整代码)
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
表格:
单击按钮打开 Windows Office 打印对话框:
我想打印一张显示在用户表单框架中的图像。
frame1.Picture = LoadPicture(spath & xPicture & ".jpg")
spath
是图片存放的完整路径
这显示了图片。
我要打印出来
是否有从用户表单执行此操作的代码,或者是否有从文件位置打印它的代码?
一个选项是通过 shell 命令调用 Windows 打印对话框。
示例:(完整代码)
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
表格:
单击按钮打开 Windows Office 打印对话框: