• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code not working anymore

govi

Member
Hi,


My code for exporting a .gif of a range worked fine but lately I get an error at this line:

Code:
chtObj.Chart.Export sFile


Can anyone help solving my problem?


Thanks,

govi


The whole code:

[pre]Sub ExportGrafiekWorkoutdata()
Sheets("grafieken_workoutdata").Select
Dim sfilename As String
Dim chtObj As ChartObject
Dim cht As Chart

sFile = "D:DropboxPortableAHKDropboxPublicworkoutworkoutdata.gif"
'sFile = "D:DropboxPublicworkoutworkoutdata.gif"

On Error Resume Next
Kill sFile
On Error GoTo 0

With Range("B1:AM47")
'.Value = 123.4567 ' just for testing of course

.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'size to range plus a bit for chart border
Set chtObj = ActiveSheet.ChartObjects.Add( _
.Left, .Top, .Width + 6, .Height + 6)
End With

chtObj.Chart.Paste
chtObj.Chart.Export sFile
chtObj.Delete

End Sub
[/pre]
 
Hi Govi,


The only possible reason for error in export file is path, I guess the path (D:dro...)is not valid, or file the file may in already open by some other application and so not able to overwrite.


Try with different path, and let us know if you still get error.


Regards,

Prasad DN
 
Back
Top