Loading an image error

Cozzy123

New Member
Joined
Aug 10, 2016
Messages
28
Hi all,

I'm probably doing something wrong, this code worked before but I'm getting a debug?

Any ideas?

Sub DrawChart()
Dim CurrentFileName As String
CurrentFileName = ThisWorkbook.Path & "\current.gif"

Dim CurrentChart As Chart
Set CurrentChart = ThisWorkbook.Sheets("Charts").ChartObjects("Compliance").Chart
CurrentChart.Export Filename:=CurrentFileName, filtername:="GIF"

Dashboard.Image1.Picture = LoadPicture(CurrentFileName)
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
For any error (compile error or runtime error) it is important to report 3 things:
1. Error number
2. Error message
3. Line of code that generates the error. (typically, you would press the 'Debug' button on the error dialog to find the line)
 
Upvote 0
Ok sorry, of course.

CurrentChart.Export Filename:=CurrentFileName, filtername:="GIF"

Run time error '-2145597210 (800c0006)
Method 'Export' of object '_Chart' failed

And its the line in Orange which is highlighted during debug

1720468864176.png
 
Upvote 0
Hi all

I've tried reworking it, but its still not working and I really don't understand why. It works on another laptop fine........................

Any guru's out there that can help with this?

Many thanks


1720526289244.png


1720526331361.png
 
Upvote 0
Where is the workbook with the code saved?
 
Upvote 0
That could be the problem. Check what value FName is returning when the code errors.
 
Upvote 0
Add:

VBA Code:
Debug.Print FName

before the Export line. That will output the result to the Immediate WIndow in the VB Editor (Ctrl+G if that's not already visible).
 
Upvote 0
Another option is to put this line of code just before the line that is returning the error:
VBA Code:
MsgBox FName
This will return a Message Box with the value of that variable at that point of the code.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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