Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How come code written by a macro won't replay in excel 2008?
Hi all,
I recorded a macro and selected a chart sheet and the chart on it and it wrote the code: ActiveSheet.ChartObjects("Chart 1").Activate I then rerean the code and was kind of surpirsed when the code came up with the message that the item was not found. There seems to be a difference between the code when it is recorded from a macro and when it is written which seems wrong to me, if the object oroducres the code in the macro when selected why on earth will it not select when it is run back, I am somewhat nonplussed! I was pretty proficient at programming excel 2003 but the latest version seems to be a lot less user friendly am I right? Thanks and regards, Mark |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How come code written by a macro won't replay in excel 2008?
On May 22, 9:46*am, wrote:
Hi all, I recorded a macro and selected a chart sheet and the chart on it and it wrote the code: ActiveSheet.ChartObjects("Chart 1").Activate I then rerean the code and was kind of surpirsed when the code came up with the message that the item was not found. There seems to be a difference between the code when it is recorded from a macro and when it is written which seems wrong to me, if the object oroducres the code in the macro when selected why on earth will it not select when it is run back, I am somewhat nonplussed! I was pretty proficient at programming excel 2003 but the latest version seems to be a lot less user friendly am I right? Thanks and regards, Mark Your code is using ActiveSheet because of how it was recorded. If you are trying to run just this piece of code while you are on a different sheet, you would receive an error that the object wasn't found if you do not have a chart on that sheet called Chart 1. Try changing it to: Sheets("ChartSheetName").ChartObjects("Chart 1").Activate If you are infact trying to run this from the sheet that contains Chart 1 and it is still telling you that the object isn't found, that is very odd unless the name of the chart changed somehow. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How come code written by a macro won't replay in excel 2008?
On May 22, 11:22*pm, JW wrote:
On May 22, 9:46*am, wrote: Hi all, I recorded a macro and selected a chart sheet and the chart on it and it wrote the code: ActiveSheet.ChartObjects("Chart 1").Activate I then rerean the code and was kind of surpirsed when the code came up with the message that the item was not found. There seems to be a difference between the code when it is recorded from a macro and when it is written which seems wrong to me, if the object oroducres the code in the macro when selected why on earth will it not select when it is run back, I am somewhat nonplussed! I was pretty proficient at programming excel 2003 but the latest version seems to be a lot less user friendly am I right? Thanks and regards, Mark Your code is using ActiveSheet because of how it was recorded. *If you are trying to run just this piece of code while you are on a different sheet, you would receive an error that the object wasn't found if you do not have a chart on that sheet called Chart 1. *Try changing it to: Sheets("ChartSheetName").ChartObjects("Chart 1").Activate If you are infact trying to run this from the sheet that contains Chart 1 and it is still telling you that the object isn't found, that is very odd unless the name of the chart changed somehow.- Hide quoted text - - Show quoted text - Yes I just tried it again and that is the case; I record the macro , select the sheet and then the chart and get this: Sheets("Chart1").Select ActiveSheet.ChartObjects("Chart 1").Activate When I step through the macro I get the error it is most odd, what could be the reason? Anyone any idea as I cannot go much further until I sove it, thanks, Mark |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How come code written by a macro won't replay in excel 2008?
Did you delete the chart and create a new one? Chances are, the new one is
named "Chart 2". This may be more likely to do what you want: ActiveSheet.ChartObjects(ActiveSheet.ChartObjects. Count).Activate - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ wrote in message ... On May 22, 11:22 pm, JW wrote: On May 22, 9:46 am, wrote: Hi all, I recorded a macro and selected a chart sheet and the chart on it and it wrote the code: ActiveSheet.ChartObjects("Chart 1").Activate I then rerean the code and was kind of surpirsed when the code came up with the message that the item was not found. There seems to be a difference between the code when it is recorded from a macro and when it is written which seems wrong to me, if the object oroducres the code in the macro when selected why on earth will it not select when it is run back, I am somewhat nonplussed! I was pretty proficient at programming excel 2003 but the latest version seems to be a lot less user friendly am I right? Thanks and regards, Mark Your code is using ActiveSheet because of how it was recorded. If you are trying to run just this piece of code while you are on a different sheet, you would receive an error that the object wasn't found if you do not have a chart on that sheet called Chart 1. Try changing it to: Sheets("ChartSheetName").ChartObjects("Chart 1").Activate If you are infact trying to run this from the sheet that contains Chart 1 and it is still telling you that the object isn't found, that is very odd unless the name of the chart changed somehow.- Hide quoted text - - Show quoted text - Yes I just tried it again and that is the case; I record the macro , select the sheet and then the chart and get this: Sheets("Chart1").Select ActiveSheet.ChartObjects("Chart 1").Activate When I step through the macro I get the error it is most odd, what could be the reason? Anyone any idea as I cannot go much further until I sove it, thanks, Mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Simple VBA Code written in Excel 2003 not working in Excel 2000 | Excel Programming | |||
Macro written with VB in Alphacam. How do I put that in Excel? | Excel Programming | |||
Problem with VBA code written in Excel 2002 working in Office 2003 | Excel Programming | |||
Compiling Excel 2003 application written in VBA 6.0 Code | Excel Programming | |||
Userfrom code in written in Excel 2000 running in Excel 97 | Excel Programming |