Slow Image Transfer

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,352
I am transferring and image to a user form, "frmAlt". The code I'm using is:

CurrentChart.Export Filename:=CurrentFileName, FilterName:="GIF"
frmAlt.Image1.Picture = LoadPicture(CurrentFileName)

Sometimes this takes between 0.15 and 0.2 seconds, but frequntly it takes between 3 and 4 seconds, or more.
Can anyone think what could be causing the delay or what might be a better way of getting the image on my form?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If you tell us where the picture is located. In a Folder? On a Sheet?
Looks like you move a chart from a sheet.
 
Upvote 0
Thanks for the reply jolivanes. Your assumption is correct, the chart is created on a veryhidden worksheet and is transferred to a userform.
 
Upvote 0
Hi

I remind you to use few images in the sheet
If you can avoid saving the image in the file
Copy it directly into memory
 
Upvote 0
In a regular module.
Code:
Sub Show_Me()
    UserForm1.Show
End Sub

UserForm (Userform1) with Image Control (Image1) and Command Button (Cmd1)
Code:
Private Sub Cmd1_Click()
'With thanks to Siddharth Rout
    Dim objChrt As ChartObject
    Dim myChart As Chart
    Dim myFileName As String, strPath As String

    strPath = ThisWorkbook.Path & "\Temp_Chart.jpg"

    Set objChrt = Sheets("Sheet1").ChartObjects(1)
    Set myChart = objChrt.Chart

    On Error Resume Next
        Kill strPath
    On Error GoTo 0

    myChart.Export Filename:=strPath, Filtername:="JPG"

    Me.Image1.Picture = LoadPicture(strPath)
    Me.Image1.PictureSizeMode = fmPictureSizeModeStretch

End Sub

Change references where required.
 
Upvote 0
Thanks for that jolivanes. It is essentially the same as my code, and unfortunately does nothing to improve the speed. I believe I have found the solution myself by removing the reference to the workbook path and simply referencing the worksheet (It's in the same workbook, which I hadn't mentioned.)
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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