Hi,

You can try this code. The code has been taken from Open XL where
through a utility a cell or range of cells are exported as image (GIF/
PNG).

//Here is the subroutine:
Sub SaveRangeAsGif()
Dim MyChart As Chart
Dim objPict As Object
Dim RgCopy As Range

On Error Resume Next
Set RgCopy = Application.InputBox("Select the range to copy / Saveas",
"Selection Save", Selection.Address, Type:=8)
If RgCopy Is Nothing Then Exit Sub

RgCopy.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
ActiveSheet.PasteSpecial Format:="Bitmap"
Set objPict = Selection

With objPict
    .CopyPicture 1, 1 ':=1
    Set MyChart = ActiveSheet.ChartObjects.Add(1, 1, .Width +
8, .Height + 8).Chart
End With

With MyChart
    .Paste
    .Export Application.GetSaveAsFilename(FileFilter:="Image File
(*.gif), *.gif")
    .Parent.Delete
End With

'// cleanup
objPict.Delete
Set RgCopy = Nothing
Set objPict = Nothing

On Error GoTo 0
End Sub

Hope this solves your problem, else feel free to write back for
clarifications.

________________________________________
Thanks & Regards
Ashish Jain
McKinsey India Knowledge Center
(Microsoft Certified Application Specialist)
(Microsoft Certified Professional)
http://www.excelitems.com
http://www.openexcel.com
________________________________________


On Sep 25, 1:14 am, LunaMoon <lunamoonm...@gmail.com> wrote:
> How do I copy some cells(including formatting) and save as image file
> using VBA?
>
> Ultimately, I want to do that via COM or ActiveX server. Yet I think
> VBA is the starting point.
>
> So lets start from VBA.
>
> How to do that in VBA?
>
> I know how to open and close the Excel sheet.
>
> But what's the command in VBA/COM/ACTIVEX  to copy a few cells
> (rectangular shape, including formatting), and save as image?

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts

Reply via email to