Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple VBA Code written in Excel 2003 not working in Excel 2000 Rich B. Excel Programming 4 August 3rd 07 04:36 PM
Macro written with VB in Alphacam. How do I put that in Excel? NickHK Excel Programming 0 January 12th 07 05:04 AM
Problem with VBA code written in Excel 2002 working in Office 2003 [email protected] Excel Programming 2 July 11th 06 08:44 PM
Compiling Excel 2003 application written in VBA 6.0 Code Heinzpeter Excel Programming 0 September 7th 05 04:48 PM
Userfrom code in written in Excel 2000 running in Excel 97 KimberlyC Excel Programming 1 February 11th 04 08:45 PM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"