Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Feb 2009
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've created a chart in excel.
    And now I want to create a pop-up to display it?
    I assume a userform will be used for the pop-up (not all that familar with them).

    Can I put the chart directly on the userform? How?
    then write a macro to display the userform? How?
    Or do I have to write a macro to copy the chart (or chartpicture) on a userform?

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I am not sure this is possible with standard controls
    BUT I'd love to learn of a solution.
    The standard Image control on a user form needs a picture file.
    Excel does not support the NET Clipboard.GetImage, or it would be easy.
    Maybe there is an API to Get an image from the clipboard.
    Andrew

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I just found a way to do it by saving a copy of the chart as an image

    Code:
    Sub GetChartDataAndShow()
    
    Dim strFile As String
    Dim cht As Chart
    
    Load frmChart   'Load Hidden
    'Select Chart
    Set cht = ActiveSheet.Shapes("Chart 1").Chart
    strFile = ActiveWorkbook.Path & "\temp.gif"
    cht.Export Filename:=strFile, FilterName:="GIF"
    'Load File to Image
    With frmChart
        .imgChart.Picture = LoadPicture(strFile)
    End With
    
    frmChart.Show
    
    End Sub
    Attached Spreadsheet has an example

    [attachment=87598:ChartOnUserForm.zip]
    Attached Files Attached Files
    Andrew

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Depending on which version of Office you have, you may be able to use the Office Web Components Chart control. The OWC was discontinued for 2007, though previous versions (version 11 seems to be the best) do still work with it if you can find them.
    The documentation is not that great though!
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Chicago, Illinois, USA
    Posts
    187
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Once you've saved the chart as an image, couldn't you then format the background of a comment box so that the image will appear when you hover over the cell?

  6. #6
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts
    That's elegant!
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

Posting Permissions

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