gpt4 book ai didi

excel - 如何打印图像?

转载 作者:行者123 更新时间:2023-12-04 20:42:03 25 4
gpt4 key购买 nike

我想打印在用户窗体的框架中显示的图像。

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

形式:

enter image description here

单击按钮打开 Windows Office 打印对话框:

enter image description here

关于excel - 如何打印图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30990717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com