I get this error even if I copy the code directly from the example in Office 2007 Help, which is this:
Dim ch As ChartObject
Set ch = Worksheets("sheet1").ChartObjects.Add(100, 30, 400, 250)
ch.Chart.ChartWizard source:=Worksheets("sheet1").Range("a1:a20"), _
gallery:=xlLine, title:="New Chart"
However, the project that I am trying to get to work is below. This code works on one machine (Vista, Office 2007) but does not work on the other (Windoes Server Edition 2003, Office 2007).
Function CopyRangeToGIF()
' save a range from Excel as a picture
Dim rng As Excel.Range
Dim cht As Excel.ChartObject
Const strPath As String = "C:\"
Application.ScreenUpdating = False
'Set rng = Range("A1").CurrentRegion
Set rng = Range("A2:w35")
rng.CopyPicture xlScreen, xlPicture
Set cht = ActiveSheet.ChartObjects.Add(0, 0, rng.Width + 10, rng.Height + 10)
cht.Chart.Paste
cht.Chart.Export "C:\Users\Paul\Desktop\myfile.png"
cht.Delete
ExitProc:
Application.ScreenUpdating = True
Set cht = Nothing
Set rng = Nothing
End Function
Any ideas? I have tried unprotecting the worksheet without any luck...
Bookmarks