在报告中插入图片并调整其大小 [英] Insert and resize a picture in a report
问题描述
我正在启动一个带有考试问题的Access数据库.几乎每个问题都会有图画.我宁愿不要将图片保存在数据库中以保持较小.
I am starting an Access database with exam questions. Almost every question will have a picture. I prefer not to save the pictures in the database to keep it small.
我想将这些图片插入报告中.图片必须全部具有相同的宽度(报告的宽度),但是必须根据原始纵横比调整高度.有些图片是风景的,有些是肖像的.
I want to insert these pictures in a report. The pictures must all have the same width (the width of the report), but the height must be resized according to the original aspect ratio. Some pictures are landscape and others portrait.
我正在使用Office 365,VBA 7.1和Windows 10.
I am using Office 365, VBA 7.1 and Windows 10.
推荐答案
最后,它非常简单.我正在发布解决方案,也许它将为其他人节省三天.
In the end it was very simple. I am posting the solution, maybe it will save somebody else three days.
只是说明名字.
ImageSource是一个包含文件路径的文本框.
ImageSource is a text box that contain the path of the file.
ImageFrame是我放在报表上的空白图像.
ImageFrame is an empty image that I placed on the report.
代码位于报表的GroupHeader的OnFormat部分中.
The code is placed in the OnFormat section of my GroupHeader on my Report.
9996略小于我的报告宽度,以缇为单位.
The 9996 is a little smaller than the width of my report and it is in twips.
这是代码:
Private Sub GroupHeader3_Format(Cancel As Integer, FormatCount As Integer)
Me![ImageFrame].Picture = Me![ImageSource]
Me![ImageFrame].Width = 9996
Me![ImageFrame].Height = 9996 * Me![ImageFrame].ImageHeight / Me![ImageFrame].ImageWidth
End Sub
这篇关于在报告中插入图片并调整其大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!