Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Export autoshape as picture using VBA? (object doesn't support met

Excel 2003, although I'd like my code to work in 2007 as well, in case I
up(?)grade.

I'm trying to export an autoshape as a picture (code below). The last line
returns a 438 error; "object does not support this property or method". I
welcome any suggestions on how to adjust the code to export an autoshape as
an image.

Overall plan- because you might have other good ideas for me to consider- I
want to use some 'custom' colors without using the color palette, but Excel
doesn't like that idea. At this point, I am trying to use only the last
custom color index; set it to my custom color, set the autoshape to that
color, save the autoshape as a picture; then change the custom color palette
back to what it was before I used it. Last, I import my autoshape as an
image, thereby retaining my custom color without requiring the ongoing use of
the palette.

My next step will be to import the "autoshape" image and try to place it
exactly where the autoshape was (and then delete the autoshape). I also need
to ensure that my image's background is transparent so that I can overlap
images and have it look the same as overlapped autoshapes.

Sub ExportShapeAsPicture()
Dim IShape As Shape
Err.Number = 0
On Error Resume Next

Set IShape = ActiveWorkbook.ActiveSheet.Shapes("AutoShape 9133")
If IShape Is Nothing Or Err.Number < 0 Then
MsgBox "Whoops, no shape by this name"
Exit Sub
End If

ShapeName = "test_i1"

UsePath = ActiveWorkbook.Path & "\" & ShapeName & ".gif"
On Error GoTo 0
IShape.Export FileName:=UsePath, FilterName:="GIF"

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Export autoshape as picture using VBA? (object doesn't support met

The Export method only works with charts, you can place (or paste) your
shape on an empty chart (no border etc) and Export the chart.

It's also possible to copy the shape, get its bmp or metafile format from
the clipboard and save to file (API stuff)

I don't quite follow the overall objective though and wonder why you need to
export the shape as an image, only to reimport it back. Concerning colours,
even in pre Excel 2007 you are not confined to the palette, eg -

shp.Fill.ForeColor.RGB = RGB(50, 150, 250)

In all versions you can also give your shape a degree of transparency from
opaque to completely transparent.

Regards,
Peer T


"ker_01" wrote in message
...
Excel 2003, although I'd like my code to work in 2007 as well, in case I
up(?)grade.

I'm trying to export an autoshape as a picture (code below). The last line
returns a 438 error; "object does not support this property or method". I
welcome any suggestions on how to adjust the code to export an autoshape
as
an image.

Overall plan- because you might have other good ideas for me to consider-
I
want to use some 'custom' colors without using the color palette, but
Excel
doesn't like that idea. At this point, I am trying to use only the last
custom color index; set it to my custom color, set the autoshape to that
color, save the autoshape as a picture; then change the custom color
palette
back to what it was before I used it. Last, I import my autoshape as an
image, thereby retaining my custom color without requiring the ongoing use
of
the palette.

My next step will be to import the "autoshape" image and try to place it
exactly where the autoshape was (and then delete the autoshape). I also
need
to ensure that my image's background is transparent so that I can overlap
images and have it look the same as overlapped autoshapes.

Sub ExportShapeAsPicture()
Dim IShape As Shape
Err.Number = 0
On Error Resume Next

Set IShape = ActiveWorkbook.ActiveSheet.Shapes("AutoShape 9133")
If IShape Is Nothing Or Err.Number < 0 Then
MsgBox "Whoops, no shape by this name"
Exit Sub
End If

ShapeName = "test_i1"

UsePath = ActiveWorkbook.Path & "\" & ShapeName & ".gif"
On Error GoTo 0
IShape.Export FileName:=UsePath, FilterName:="GIF"

End Sub



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
How to modify callouts in the InsertPictureAutoShape in Excel cathead Excel Discussion (Misc queries) 1 August 8th 07 05:45 PM
Object doesn't support... davegb Excel Programming 2 January 18th 07 02:43 PM
438 - Object doesn't support this property or method Revtim Excel Programming 0 September 12th 05 09:09 PM
Object doesn't support this method Andibevan[_4_] Excel Programming 3 September 1st 05 10:07 AM
Export html page to Excel - support files folder Export html page to Excel - support file Excel Discussion (Misc queries) 1 June 24th 05 12:36 PM


All times are GMT +1. The time now is 01:14 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"