【发布时间】:2016-08-26 11:36:19
【问题描述】:
我在 Microsoft Access 中使用 VBA 使用 Wia 扫描和保存图像。
保存图像的文件路径应设置为当前单元格的值。
我不知道如何做到这一点,但在学习了如何使用 Wia 之后,这似乎是一件容易的事。
这是我当前扫描文档的代码。
Function scanImage() As String
Dim imagePath As String
Dim folder As String
folder = "C:\Users\username\Pictures\scans\"
Dim tempName, obj
Set obj = CreateObject("Scripting.FileSystemObject")
tempName = obj.GetTempName
Dim filename
filename = Now
filename = Replace(filename, ".", "_")
filename = Replace(filename, " ", "_")
filename = Replace(filename, ":", "_")
imagePath = folder & filename & ".jpg"
Dim dev As Device
Dim wiaDialog As New WIA.CommonDialog
Dim wiaImage As WIA.ImageFile
Set dev = wiaDialog.ShowSelectDevice
Set wiaImage = wiaDialog.ShowAcquireImage
wiaImage.SaveFile (imagePath)
scanImage = imagePath
End Function
【问题讨论】:
-
Access 中没有“单元格”
-
好吧,我可以在“单元格”的设定值处创建数据库列。如果这是正确的词汇表,我如何访问和操作“数据库条目”? :)
-
你有很多东西要学——这里写的太多了。你真的应该浏览一下初学者的教程并通过示例代码来完成。