ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   XL Free Floating (https://www.excelbanter.com/excel-programming/321874-xl-free-floating.html)

11Oppidan

XL Free Floating
 
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.



Peter Huang [MSFT]

XL Free Floating
 
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(applic ationObject.Sheets("Sheet1
").Range("A1:A21"), Excel.XlRowCol.xlColumns)


applicationObject.ActiveChart.Location(Excel.XlCha rtLocation.xlLocationAsObj
ect, Name:="Sheet1")
With applicationObject.ActiveChart
.HasTitle = False
End With
applicationObject.Worksheets("Sheet1").ChartObject s(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.



All times are GMT +1. The time now is 05:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com