LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Export picture as gif in Excel

Joe,

As far as I am aware, yes. This is something I came up with earlier this
week in response to another post. There are other similar solutions out
there too. I haven't tested this much, but it seems to work ok.

Sub Test()
CopyRangeAsGif Selection, "c:\temp\test.gif"
End Sub

Sub CopyRangeAsGif(rngCells As Range, strLocation As String)
Dim chNew As Chart
Dim chObj As ChartObject
Dim lWidth As Long
Dim lHeight As Long
Dim nCounter As Integer
Dim shSource As Worksheet

On Error GoTo 0
If InStr(rngCells.Address, ",") 0 Then
MsgBox "Non contiguous range not permitted"
Exit Sub
End If

With rngCells
For nCounter = 1 To .Columns.Count
lWidth = lWidth + .Columns(nCounter).Width
Next nCounter

For nCounter = 1 To .Rows.Count
lHeight = lHeight + .Rows(nCounter).Height
Next nCounter

End With

Set chNew = Charts.Add

chNew.Location Whe=xlLocationAsObject, Name:=rngCells.Parent.Name
Set shSource = rngCells.Parent
Set chObj = shSource.ChartObjects(shSource.ChartObjects.Count)
rngCells.CopyPicture xlScreen, xlPicture

With ActiveChart
.Paste
.ChartArea.Border.LineStyle = 0
.ChartArea.ClearContents
End With

chObj.Width = lWidth + 4
chObj.Height = lHeight + 4
chObj.Chart.Export strLocation, "GIF", False

rngCells.Select
chObj.Delete
End Sub


--
Robin Hammond
www.enhanceddatasystems.com
Check out our XspandXL add-in


"Joe 90" wrote in message
...
I like the way one can export a chart to a gif, is it possible to export a
picture in Excel. I like the way one can program to take a "picture of a
range of cells, but want to be able to export this picture as a gif. is

the
only way to put it in a blank chart?

Thanks




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect a number to a picture bank and import that picture to exce Dennis Hedo Excel Discussion (Misc queries) 1 March 22nd 10 02:17 PM
Export Excel tuncating leading zeros while export to excel from da RHBKV Setting up and Configuration of Excel 1 July 15th 09 01:48 PM
export re-order input fields to export file [csv] madisonpete Excel Worksheet Functions 0 November 30th 07 03:51 PM
insert a picture in to a comment but picture not save on hard disk Pablo Excel Discussion (Misc queries) 0 February 21st 07 03:48 PM
How to extract a picture from an Excel worksheet into a picture fi SARANJAI Excel Discussion (Misc queries) 10 June 12th 05 05:00 AM


All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"