Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why This Macro Only Work On One Sheet ? (Excel 2000)

    I try to use this macro on several sheets that have a chart on it (converting chart into picture), but it only worked on one. When I go to another sheet, it gives me problem at the last line. Can someone help ? Many many thanks.

    Sub test()
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.ChartArea.Select
    ActiveWindow.Visible = False
    ActiveWindow.WindowState = xlNormal
    ActiveWindow.WindowState = xlMaximized
    Range("B7").Select
    ActiveSheet.Pictures.Paste.Select
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why This Macro Only Work On One Sheet ? (Excel 2000)

    There seem to be several superfluous instructions in your macro. Try this instead:

    Sub Test()
    With ActiveSheet
    .ChartObjects(1)CopyPicture
    .ChartObjects(1).Delete
    .Paste .Range("B7")
    End With
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why This Macro Only Work On One Sheet ? (Excel 2000)

    Hans,

    Thanks as always for your help. However, I got stuck at the second line: .ChartObjectis(1)CopyPicture. It says compliler error, syntax error.

    TQ

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Why This Macro Only Work On One Sheet ? (Excel 2000)

    I'm sorry, that's what you get for writing air code.<pre>.ChartObjects(1)CopyPicture</pre>

    should have been<pre>.ChartObjects(1).CopyPicture</pre>

    Note: not ChartObjectis.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2003
    Posts
    174
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Why This Macro Only Work On One Sheet ? (Excel 2000)

    Hans,

    Many thanks. I should blame my own ignorance.

    Erxin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •