Jack has attended:
Excel VBA Intermediate course
Storing bitmap objects within VBA.
How does one store bitmaps in VBA. The idea is to have ifs choosing different headers images on user input. However, for that, the pictures have to be saved within the .xlsm package but not shown anywhere on the worksheet(ideally).
RE: Storing bitmap objects within VBA.
Hello Jack,
I have referred your question to a colleague of mine who might be able to assist you. He is training today and tomorrow, so I expect he should get back to you on Wednesday.
Sorry for the inconvenience!
Kind regards
Marius Barnard
Excel Trainer
RE: Storing bitmap objects within VBA.
Hi Jack,
Thank you for the forum question.
Yes unfortunately the bitmaps must be saved in a worksheet to be able to use them in VBA code. You can hide the worksheet and workbook project the structure so no one can access or see the bitmaps without a password.
You can embed the image each time and then delete it again when you run the macro and want another image.
I hope the code below can help you.
Sub AddImage()
Dim Pic As Object
Application.ScreenUpdating = False
On Error Resume Next
For Each Pic In ActiveSheet.Pictures
Pic.Delete
Next Pic
On Error GoTo 0
'the destination of the picture
Range("a1").Select
'the source
ActiveSheet.Pictures.Insert("C:\Users\jens\Desktop\Excel Advanced VBA\test.bmp").Select
Selection.ShapeRange.LockAspectRatio = msoFalse
'resize image
Selection.ShapeRange.Height = 30
Selection.ShapeRange.Width = 50
Application.ScreenUpdating = True
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector