PDA

View Full Version : Solved: Inserting Picture in charts thru VBA



rajkumar
01-05-2009, 03:35 PM
Hi Experts,

I need help on inserting a picture in bar chart. I am having all the pictures in c: drive in a specific folder. (Enhanced Metafile format).

For which i recorded a macro which doing the job neatly for me.

but my problem is i do not know how to determine my selection to plot by rows or by columns.

and also not knowing how to place the chart in specific sheet.

The attached sample workbook has the macro which creates a chart sheet instead of an chart object.

1. is it possible to detect the selection is by rows or by columns
to plot the chart.
2. is it possible to insert a picture or a drawing object within the worksheet instead of an extrnal picture file
3. i want to create the chart in a specific sheet as an object, not as a chart sheet.
my macro is

Sub Macro1()
Dim myrng As Range
Set myrng = selection
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=myrng, PlotBy:= _
xlColumns
ActiveChart.Location Where:=xlLocationAutomatic
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False

End With
ActiveChart.Legend.Delete
ActiveChart.SeriesCollection(1).Select
With selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
selection.Shadow = False
selection.InvertIfNegative = False
selection.Fill.UserPicture PictureFile:= _
"C:\Documents and Settings\Rajkumar Rao.R\Desktop\Heat Roll.emf", _
PictureFormat:=xlStretch, PicturePlacement:=xlAllFaces
selection.Fill.Visible = True
End Sub


Any help would be highly appreciated

Raj :dunno

Artik
01-05-2009, 06:39 PM
Look in attached file.

Artik

rajkumar
01-05-2009, 09:59 PM
Great! it is perfectly fine for me. Thx a lot:friends: