vba - 从 Access 导出图标图像的最佳方法?
问题描述
我在 Access 表单上有大约 50 个图标图像 (.ico),但是我没有将它们存储在磁盘上。我想将它们从 Access 导出到磁盘位置。
我在这个线程上尝试了建议的解决方案:
我无法打开生成的文件,可能是因为我的图像是 (.ico) 而不是 (.png)
编辑:我可以将图标复制到绘画中,将它们保存为 png,然后使用在线转换器将它们转换为图标。相当耗时,但它有效。
解决方案
您可以使用此代码打击。
它会将所提供表单的所有图像控件的内容保存到同一文件夹中的文件中。
请注意,某些图像控件包含“奇怪的”二进制格式,每个工具可能无法正确显示这些格式。
此外,您必须注意在导出自己后分配正确的文件扩展名。
将代码放在一个新模块中,然后在设计视图中打开表单并像这样调用它:SaveAllImageControls Forms("MyForm")
Public Sub SaveAllImageControls(ByRef sourceForm As Form)
Dim item As control
For Each item In sourceForm.Controls: Do
If item.ControlType <> acImage Then Exit Do
If IsNull(item.PictureData) Then Exit Do
Dim bArray() As Byte
bArray = item.PictureData
Dim filename As String
filename = Application.CurrentDb.Name & "-" & sourceForm.Name & "-" & item.Name & ".binary"
Dim fileNumber As Integer
fileNumber = FreeFile
Open filename For Binary As fileNumber
Put fileNumber, , bArray
Close fileNumber
Loop While False: Next item
End Sub
推荐阅读
- sql - 用条件连接三个表的 SQL 查询
- javascript - 切换功能不起作用 div 元素不出现
- r - 跨多列的每一行的最小(或最大值)值
- java - 使用 Java 驱动程序解析 Mongo DBRef
- java - 创建错误类,将其移回原始位置
- kubernetes - 如何访问和更改 Kubernetes 中的默认调度程序代码。没有自定义调度程序
- c# - 如何在 WPF 应用程序中将 DataGrid 导出为 XML?
- google-sheets - 使用 Google Sheets API v4 执行结构化查询时收到“无效 JSON 有效负载错误”
- c++ - 错误:重新定义函数模板(或 C2995)
- symfony4 - 在 redirectToRoute() 之后 Symfony 4 闪烁消息不起作用