Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Creating an image file

I'm looking for some VBA code that will take an appropriately scaled
matrix and turn it into a saved image file of some sort (e.g., BMP).
Can anyone help?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Creating an image file

Hi Jim

See Harald's code on David's site
http://www.mvps.org/dmcritchie/excel/xl2gif.htm

Or use this small example to save the selection in C:\

Sub Testing()
Application.ScreenUpdating = False
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

Set ctoTheChartHolder = ActiveSheet.ChartObjects.Add(0, 0, 800, 600)

Set chtTheChart = ctoTheChartHolder.Chart

' Paste the picture onto the chart and
' set an object variable for it
ctoTheChartHolder.Activate
With chtTheChart
.ChartArea.Select
.Paste
Set picThePicture = .Pictures(1)
End With

' Set the picture's properties...
With picThePicture
.Left = 0
.Top = 0
sglWidth = .Width + 7
sglHeight = .Height + 7
End With

' Change the size of the chart object to fit the picture
'better
With ctoTheChartHolder
.Border.LineStyle = xlNone
.Width = sglWidth
.Height = sglHeight
End With
' Export the chart as a graphics file
blnRet = chtTheChart.Export(Filename:="c:\range.gif", _
FilterName:="gif", Interactive:=False)
ctoTheChartHolder.Delete
Application.ScreenUpdating = True
End Sub


--
Regards Ron De Bruin
http://www.rondebruin.nl



"Jim" wrote in message ups.com...
I'm looking for some VBA code that will take an appropriately scaled
matrix and turn it into a saved image file of some sort (e.g., BMP).
Can anyone help?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Creating an image file

Thanks Ron. That is some cool stuff. I love it.

But, I guess I wasn't clear about what I wanted.
I'd like to create a gif or a bmp from an array such that each element
of the array contains the color of a single pixel. For instance in a
really simplified example, I'd like to convert the array
{0,63,127,255} into a 1 x 4 image gray-scale image.

Do you have any help for this problem?

Thanks,
Jim

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Creating an image file

Do you have any help for this problem?

No, sorry

--
Regards Ron De Bruin
http://www.rondebruin.nl



"Jim" wrote in message ups.com...
Thanks Ron. That is some cool stuff. I love it.

But, I guess I wasn't clear about what I wanted.
I'd like to create a gif or a bmp from an array such that each element
of the array contains the color of a single pixel. For instance in a
really simplified example, I'd like to convert the array
{0,63,127,255} into a 1 x 4 image gray-scale image.

Do you have any help for this problem?

Thanks,
Jim



Reply
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
Creating a "sensitive regions" image on a form Zorro[_4_] Excel Programming 1 May 13th 06 09:45 AM
Can I get a chart to an image file? Lynda[_2_] Excel Programming 5 January 31st 05 08:57 PM
Creating image which refer to a section of another sheet holysoul[_3_] Excel Programming 0 May 11th 04 03:46 PM
Export the worksheet background image as an image file - possible? DataFreakFromUtah Excel Programming 2 April 10th 04 04:49 PM
Resizing an image file Giulio Cifelli Excel Programming 3 February 12th 04 01:23 PM


All times are GMT +1. The time now is 04:40 PM.

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"