0

I am working on a project of a memory card game (where all cards are hidden and you have to find pairs of cards by looking at 2 cards at a time), so I made the code works with letters inside of cells and displaying "[x]" for hidden cards.

Now I am trying to move to images, the problem is : I can't just put the *.jpg in the folders, Images need to be embedded in the excel file, so I created a "Data" sheet with all my images (hidden and unhidden). They are named as follow : "christmashidden", "christmasA", "christmasB" etc..

Now i wan't to have my macro to take these shapes and copy them to another worksheet (the "Plate" worksheet for instance) dynamically. So i'm about to create a function like :

Function PlaceImgInCell(Target As Range, PairID As String, ThemeName As String) As Shape
'This function will be called by the main function to place a specific image in a specific cell
'and return the image shape object if any manipuation is needed afterward

Dim TargetImg As Shape
Dim BaseImg As Shape

Set BaseImg = ThisWorkbook.Worksheets("Data").Shapes(ThemeName & PairID) 'l'image de base, on la duplique pour la placer au bon endroit
BaseImg.Copy

but I think that copying and pasting each relevant shape everytime we need to change from hidden to shown might be long to display and not efficient, but i don't know any other way to do, what are the options at my disposal ? Thanks !

HugoGh
  • 3
  • 1
  • 3
  • Use a `UserForm`? Much more easier to display images? – Siddharth Rout Nov 27 '20 at 17:00
  • https://stackoverflow.com/questions/56088220/excel-vba-macro-to-move-shapes-to-a-different-shape-without-copying-and-past – braX Nov 27 '20 at 17:05
  • Thanks for the answer guys, I think using a userform will imply a lot more work than just using Excel Shapes no ? BraX, i saw already this answer but i don't see any way to create a shape and then apply to it another shape's picture, if you know how to do it then i'm all ears ! – HugoGh Nov 27 '20 at 17:09

0 Answers0