Function ReplaceImage(strReportName As String, _
Optional bSaveAndClose As Boolean, Optional bHidden As Boolean)
'Purpose: Replace Logo Image on Reports
Dim rpt As Report 'Form
Dim ctl As Control
Dim bChanged As Boolean
'Open the form in design view
DoCmd.OpenReport strReportName, acDesign, acHidden, acWindowNormal
Set rpt = Reports(strReportName)
'Find the images that are old logo
For Each ctl In rpt.Controls
If ctl.ControlType = acImage Then
If ctl.Picture = "C:\Pics\Logo1.bmp" Then
ctl.Picture = "C:\Pics\Logo2.jpg"
ctl.SizeMode = 1 '=stretch/shrink to fit
bChanged = True
End If
End If
Next
Set ctl = Nothing
Set rpt = Nothing
If Not bChanged Then
DoCmd.Close acReport, strReportName, acSaveNo
ElseIf bSaveAndClose Then
DoCmd.Close acReport, strReportName, acSaveYes
End If
End Function