Results 1 to 1 of 1

Thread: [Excel 2010] Run-time error 1004 at ".Chart.Paste" command

Hybrid View

  1. #1
    New Member
    Join Date
    Aug 11
    Posts
    9

    [Excel 2010] Run-time error 1004 at ".Chart.Paste" command

    Hi all,

    My employer is planning to move to Windows 7 and Office 2010 as existing computers come up for replacement. I have a program (developed by someone else who has since left the organisation) which runs fine on our outgoing Windows XP / Excel 2003 platform but which is crashing at a couple of points during testing on my own Windows 7 / Excel 2010 laptop at home. It previously worked fine on a Windows 7 / Excel 2007 combination.

    The first, more critical probem occurs in a section of code which takes charts held within worksheets, exports them as Bitmap files and then displays them within a UserForm. In W7/E2010 I get "Run-time error '1004': Application-defined or object-defined error" at the .Chart.Paste line (I've posted the whole procedure for context).

    Code:
    Sub TableShow(sheet, range, specialType, fileName, formName, imgName)
    
        Call Version
    
    '   Variables for chart & file name
        Dim currentRange As range
        Dim fName As String
        Dim myCell As range
    
    '   Variable is set to chart within 'Data' worksheet
        Set currentRange = Sheets(sheet).range(range).SpecialCells(specialType)
        x = currentRange.Width
        y = currentRange.Height
    
    '   Save chart as GIF or BMP into temp directory
        fName = ThisWorkbook.path & "\" & fileName & "ForDeletion." & filter
        
    '   chart as transition and use .ClearContents
        currentRange.CopyPicture xlScreen, xlPicture
        With currentRange.Worksheet.ChartObjects.Add(0, 0, x, y)
        .Height = y
        .Width = x
        .Chart.Paste
        .Chart.Export fileName:=fName, FilterName:=filter
        .Delete
        End With
        
    '   Insert chart into image control on form
        imgName.Visible = True
        imgName.Width = x
        imgName.Height = y
        imgName.Picture = LoadPicture(fName)
        formName.Width = x + 60
        
    End Sub
    I'd be hugely grateful for any help or pointers!

    Cheers,
    John
    Last edited by JohnnyMac78; Aug 2nd, 2012 at 01:16 PM.

Posting Permissions

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