Consulting

Results 1 to 2 of 2

Thread: Chart in userform without creating a image temporary file

  1. #1

    Question Chart in userform without creating a image temporary file

    Hi,

    I've just made it to create a chart in a userform by creating the chart in the background (in the table) and exporting it as a jpeg-file saved locally. this is actually the only solution i've found in the internet so far.

    is it possible to do this without creating a new jpeg file on the hard drive ? so i just wanna create a chart in the table and have it shown as an image in my userform.. or like saving the image temporarily in a table if possible. here is an extract of my code:

    (...)

    Dim MyChart As Chart
    Dim ChartName As String


    ChartName = "Open/Closed"


    Set MyChart = Sheets("datenfuerauswahlfelder").Shapes.AddChart(xlColumnStacked).Chart

    For Each s In MyChart.SeriesCollection
    s.Delete
    Next s

    MyChart.SeriesCollection.Add _
    Source:=Worksheets("datenfuerauswahlfelder").Range("p4:s4")


    MyChart.SeriesCollection(1).HasDataLabels = True
    MyChart.SeriesCollection(1).Name = "Priority 2"

    MyChart.SeriesCollection(1).XValues = Sheets("datenfuerauswahlfelder").Range("P2:s2")

    MyChart.Refresh

    MyChart.SeriesCollection.NewSeries

    MyChart.SeriesCollection(2).HasDataLabels = True
    MyChart.SeriesCollection(2).Name = "Priority 1"
    MyChart.SeriesCollection(2).Values = Sheets("datenfuerauswahlfelder").Range("P3:S3")

    MyChart.ChartArea.Format.TextFrame2.TextRange.Font.Size = 13


    MyChart.Refresh


    With MyChart.Parent
    .Height = 330
    .Width = 540

    End With



    Dim imageName As String
    imageName = Application.DefaultFilePath & Application.PathSeparator & "TempChart.jpeg"
    MyChart.Export Filename:=imageName, FilterName:="jpeg"

    (...)


    greetings

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Check here: http://www.andypope.info/vba/userformdraw.htm

    I think you should be able to use Andy Pope's code.

    Mark

Tags for this Thread

Posting Permissions

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