XL Free Floating

1

11Oppidan

Hi,

With Excel VBA one is able to set the placement of a chart = xlfreefloating
so that it is size is not affected by for example increasing the column
size under the chart.

I would like to do the same thing programmatically using VB .NET VS 2003 in
an excel addin application - but I cannot get it to work. Does any one have
an example how to do this in VB .NET or any example sites I could visit
which give good examples of making complex charts with VB .NET it would be
much appreciated.

Thank you for any assistance.
 
P

Peter Huang [MSFT]

Hi

Here is the code snippet which will draw a chart based on the range(a1:a21)
which will have the xlfreefloating style as we do in VBA.
Public Sub Test()
applicationObject.Charts.Add()
applicationObject.ActiveChart.ChartType =
Excel.XlChartType.xlXYScatter

applicationObject.ActiveChart.SetSourceData(applicationObject.Sheets("Sheet1
").Range("A1:A21"), Excel.XlRowCol.xlColumns)


applicationObject.ActiveChart.Location(Excel.XlChartLocation.xlLocationAsObj
ect, Name:="Sheet1")
With applicationObject.ActiveChart
.HasTitle = False
End With
applicationObject.Worksheets("Sheet1").ChartObjects(1).Placement =
Excel.XlPlacement.xlFreeFloating
End Sub

I think a better approach is to record the macro in the excel, and we will
get the vba code.
And it is easy to turn the vba code into vb.net code.

If you still have any concern, please feel free to post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top