Good day.
Just for fun I've been programming a game in Excel VBA. I've been working on this for most of this year. I am using MSoffice 2021.
Suddenly, code that has literally worked for 10 months now just plain stopped working. Here is the code:
' Got to the game pictures page and get the init pic (World Gate)
Sheets("GamPic").Select
For Each MyShp In ActiveSheet.Shapes
If MyShp.Name = MyshpName Then
MyShp.Select
Selection.Copy
Sheets("Interface").Select
ActiveSheet.Range("J5").Select
ActiveSheet.Paste
ActiveSheet.Range("T29").Select
Exit For
End If
Next MyShp
The code crashes at the ActiveSheet.Past line. It says "Paste method of worksheet class failed"
I'm thinking that something has changed in Excel. If I run the code under Excel 2007 it runs flawlessly. I've tried other things such as selecting the cell J5 and then manually pressing cntrl v and it will paste in the shape (an image). So I took out the activesheet.paste and used SendKeys("^v") and it will not work unless I change the Exit For command to Exit Sub.
Any ideas on what I've done wrong and how to fix it?
Thank you for your help
JD
Just for fun I've been programming a game in Excel VBA. I've been working on this for most of this year. I am using MSoffice 2021.
Suddenly, code that has literally worked for 10 months now just plain stopped working. Here is the code:
' Got to the game pictures page and get the init pic (World Gate)
Sheets("GamPic").Select
For Each MyShp In ActiveSheet.Shapes
If MyShp.Name = MyshpName Then
MyShp.Select
Selection.Copy
Sheets("Interface").Select
ActiveSheet.Range("J5").Select
ActiveSheet.Paste
ActiveSheet.Range("T29").Select
Exit For
End If
Next MyShp
The code crashes at the ActiveSheet.Past line. It says "Paste method of worksheet class failed"
I'm thinking that something has changed in Excel. If I run the code under Excel 2007 it runs flawlessly. I've tried other things such as selecting the cell J5 and then manually pressing cntrl v and it will paste in the shape (an image). So I took out the activesheet.paste and used SendKeys("^v") and it will not work unless I change the Exit For command to Exit Sub.
Any ideas on what I've done wrong and how to fix it?
Thank you for your help
JD