I have the code below in a macro and it copies the data in Range("C26:D38") and saves it as a png file. After it saves the data once, I have code copying and pasting data over this info. I would then like to export the data again (it has now been updated), as a different file name. When I tried to do this it gave me an error "COMPILE ERROR DUPLICATE DECLARATION IN CURRENT SCOPE."
I assume this means that VBA code is not read top to bottom (like a book) and I need to change something each time I insert the code in the macro. I'm not sure what to change though. Any ideas?
Thanks!!
I assume this means that VBA code is not read top to bottom (like a book) and I need to change something each time I insert the code in the macro. I'm not sure what to change though. Any ideas?
Thanks!!
Code:
' save a range from Excel as a picture
Dim rng As Excel.Range
Dim cht As Excel.ChartObject
Const strPath As String = "C:\Documents and Settings\CB021\Desktop\Real time stats web\images\"
Application.ScreenUpdating = False
Set rng = Range("C26:D38").CurrentRegion
rng.CopyPicture xlScreen, xlPicture
Set cht = ActiveSheet.ChartObjects.Add(0, 0, rng.Width + 0.01, rng.Height + 0.01)
cht.Chart.Paste
cht.Chart.Export strPath & "OrdersShipped_text.png"
cht.Delete
ExitProc:
Application.ScreenUpdating = True
Set cht = Nothing
Set rng = Nothing
Last edited by a moderator: