gpt4 book ai didi

excel - 从用户表单导出图像

转载 作者:行者123 更新时间:2023-12-04 22:31:20 24 4
gpt4 key购买 nike

我有一个面板控件,它以从工作表“图表”中的图表生成的用户表单显示图像。它们依赖于具有“预览”按钮的组合框2,该按钮在辅助用户窗体中以完整质量显示图表的图像。

我一直在尝试做的是制作一个导出按钮,让用户能够通过选择路径将图像下载到他们的 PC(因为工作簿位于共享文件夹中)。
但问题出现在我试图导出的图像中。我需要一种方法来获取 image2 中的事件图片(即在第二个用户表单中),以便用户可以下载它。

这是我到目前为止所拥有的,但我从 Set oChart 得到“什么都没有” , 我需要用选定的图像以某种方式填充它

Function GetFolder1() As String

Dim fldr As FileDialog
Dim oChart As Chart
Dim sitem As String

Set oChart = Image2.Picture

Set fldr = Application.FileDialog(msoFileDialogFolderPicker)

With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode

GetFolder1 = .SelectedItems(1)

oChart.Export Filename:=GetFolder1 & ("\") & ComboBox2.Text & (".bmp")
End With

NextCode:

Set fldr = Nothing
End Function

(从这个网页得到这个代码)
谢谢!

最佳答案

使用SavePicture方法。当您将图片加载到 Image 控件中时,不需要 Chart。

Public Sub SavePictureToDisk()

Dim fldr As FileDialog

Set fldr = Application.FileDialog(msoFileDialogFolderPicker)

With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = Application.DefaultFilePath
If .Show <> -1 Then GoTo NextCode

GetFolder1 = .SelectedItems(1)

'/ Here save the ImageControl's picture to disk.
SavePicture UserForm2.Image2.Picture, GetFolder1 & ("\") & comboBox2.Text & ".bmp"
End With

NextCode:

Set fldr = Nothing

End Sub

关于excel - 从用户表单导出图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52520686/

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