如何在表单上显示 MS Access Table 附件或存储在 SharePoint 位置的图像?
How do I display an MS Access Table Attachment or an image stored in a SharePoint location on a form?
我正在使用 Microsoft Access for Office 365 为工作项目制作一个小游戏。我有一个 table,其中包含所有答案和一张存储为附件的相关图片。用户将通过 SQL 查询滚动浏览记录源提供的记录。
我想在用户导航时显示与每条记录相关的图像。
我更愿意将图像存储在别处,但并非所有目标用户都可以访问公共网络文件夹。我确实可以访问常见的 SharePoint 位置,我可以在链接的 SharePoint 列表中上传他们的结果,但是当我尝试从 SharePoint 位置插入图像时,MS Access 不允许“网址”。
在测试中,我使用 VBA 通过子表单上的图片 属性 将图像(托管在网络文件夹中)显示为背景,但因为并非所有用户都访问公共网络文件夹,我无法在生产环境中执行此操作。 (创建后发现没有common文件夹。)
如何在附件中显示该图片?
或
如何使用 SharePoint 托管图像?
使用 'out of the box' MS Access 可以实现这些吗?
编辑:使用 .accdr 格式防止用户查看 tables
中的答案
因为你会有图片的 URL,你可以使用我的奇特函数 UrlContent:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:\somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = "\"
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
可以在我的项目中找到完整代码、文档和演示 VBA.PictureUrl。
我正在使用 Microsoft Access for Office 365 为工作项目制作一个小游戏。我有一个 table,其中包含所有答案和一张存储为附件的相关图片。用户将通过 SQL 查询滚动浏览记录源提供的记录。
我想在用户导航时显示与每条记录相关的图像。
我更愿意将图像存储在别处,但并非所有目标用户都可以访问公共网络文件夹。我确实可以访问常见的 SharePoint 位置,我可以在链接的 SharePoint 列表中上传他们的结果,但是当我尝试从 SharePoint 位置插入图像时,MS Access 不允许“网址”。
在测试中,我使用 VBA 通过子表单上的图片 属性 将图像(托管在网络文件夹中)显示为背景,但因为并非所有用户都访问公共网络文件夹,我无法在生产环境中执行此操作。 (创建后发现没有common文件夹。)
如何在附件中显示该图片?
或
如何使用 SharePoint 托管图像?
使用 'out of the box' MS Access 可以实现这些吗?
编辑:使用 .accdr 格式防止用户查看 tables
中的答案因为你会有图片的 URL,你可以使用我的奇特函数 UrlContent:
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:\somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = "\"
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
可以在我的项目中找到完整代码、文档和演示 VBA.PictureUrl。