T
Tim Johnson
I have been updating an Access database that contains an embedded logo in a
report. The owner of the database asked me if it would be possible to export
the Report to Excel in a manner that maintained the formatting and layout of
the report (Access' current Export to Excel simply outputs the recordset,
dropping any formatting). I've come up with a workaround for all of the
information within a report except for an embedded image. I can place the
image into a spreadsheet using code if it has a static path, or by promting
the user for a path EVERY time they export, but this is less than ideal. I'm
not terribly familliar with the vba that Excel uses, and have only been able
to get this far (code is in an Access Event):
Dim xlApp as Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim imgPic as Image
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
Set imgPic = Reports!rptMyReport!Controls!imgLogo
With xlBook.ActiveSheet.Range("a1")
Set myPict = .Parent.Pictures.Insert(imgPic)
End With
This returns Run-Time error 1004: Unable to get the insert property of the
Pictures class.
If I put in a static pathname instead of the imgPic object or use code to
prompt the user for the image location, all's well, but
for my purposes, this will not work. Excel's vba help file is less than
helpful on this matter.
Does anybody have any ideas they'd mind throwing at me?
Thanks in advance,
Tim
report. The owner of the database asked me if it would be possible to export
the Report to Excel in a manner that maintained the formatting and layout of
the report (Access' current Export to Excel simply outputs the recordset,
dropping any formatting). I've come up with a workaround for all of the
information within a report except for an embedded image. I can place the
image into a spreadsheet using code if it has a static path, or by promting
the user for a path EVERY time they export, but this is less than ideal. I'm
not terribly familliar with the vba that Excel uses, and have only been able
to get this far (code is in an Access Event):
Dim xlApp as Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim imgPic as Image
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
Set imgPic = Reports!rptMyReport!Controls!imgLogo
With xlBook.ActiveSheet.Range("a1")
Set myPict = .Parent.Pictures.Insert(imgPic)
End With
This returns Run-Time error 1004: Unable to get the insert property of the
Pictures class.
If I put in a static pathname instead of the imgPic object or use code to
prompt the user for the image location, all's well, but
for my purposes, this will not work. Excel's vba help file is less than
helpful on this matter.
Does anybody have any ideas they'd mind throwing at me?
Thanks in advance,
Tim