Load image to Imagebox

Mumba

New Member
Joined
May 3, 2018
Messages
14
Hi all

I am trying to upload a graph into a imagebox in a userform. The code is the second part of a bigger code, thats why all variable are public
I can't seem to figure out what the issue is in my code. I am getting a "Object required" error, but as far as i can se from what ever codes i have researched i should be covered? i am unable to solve it.

Code:
Public co As Object
Public ct As Chart
Public sc1 As SeriesCollection
Public ser1 As Series
Public fname As String
'Public Rng As Range

Sub CreateChart()
    wsUF.Activate
'lr2 = wsUF.Cells(100, "A").End(xlUp).Row
lc2 = wsUF.Cells(1, "T").End(xlToLeft).Column
    
    Set co = wsUF.ChartObjects.Add(Range("B15").Left, Range("B15").Top, 500, 300)
        co.Name = "Supplier Performance"
    Set ct = co.Chart
    
    With ct
        .HasLegend = True
        .HasTitle = True
        .ChartTitle.Text = "Suppler Performance"
        .ClearToMatchStyle
        .ChartStyle = 233
       
        Set sc1 = .SeriesCollection
        Set ser1 = sc1.NewSeries
        
            With ser1
                .Name = wsUF.Cells(2, "A").Value
                .XValues = Range(wsUF.Cells(1, "B"), wsUF.Cells(1, lc2 - 1))
                .Values = Range(wsUF.Cells(2, "B"), wsUF.Cells(2, lc2 - 1))
                .ChartType = xlLine
            End With  
    End With

        fname = ThisWorkbook.Path & "\temp.gif"
        ct.Export Filename:=fname, FilterName:="gif"
        Image1.Picture = LoadPicture(fname)
     
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
It looks like you haven't defined your object variable wsUF...
 
Upvote 0

Forum statistics

Threads
1,223,367
Messages
6,171,672
Members
452,416
Latest member
johnog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top