Hi
Cant get this code to work.
I havent written it myself, it's someone that worked on our company several years ago.
It has worked says my collegs.
I think it was written an worked with excel 2003,
This part shall position the chart and its objects in worksheet 1
It works until its time to arrqange the plotareaobject and I can't think out why.
I know to little VBA. I just have to make this sheet work.
I hope someone can help me...
Function arrangeChartLayout(antalUppdrag As Integer) As Boolean
' Placerar om diagramet och justerar dess storlek beroende på
' hur många uppdrag användaren har matat in.
' Justerar även diagramets olika delar för att utnyttja platsen bra
Dim chartObjectObj As ChartObject
Dim chartAreaObj As ChartArea
Dim plotAreaObj As PlotArea
Dim legendObj As Legend
Dim theSheet As Worksheet
Set theSheet = ThisWorkbook.Sheets(1)
Set chartObjectObj = ThisWorkbook.Sheets(1).ChartObjects(1)
Set chartAreaObj = chartObjectObj.Chart.ChartArea
Set plotAreaObj = chartObjectObj.Chart.PlotArea
Set legendObj = chartObjectObj.Chart.Legend
' Ändra storlek på diagram
With chartObjectObj
.Left = 100
.Top = theSheet.Rows(antalUppdrag + 3).Top
.Height = Range("A" & CStr(antalUppdrag + 3) & _
":A36").Height
.Width = theSheet.Range("A1:O1").Width - 100
End With
' Ändra placering och storlek på Legend och PlotArea
With plotAreaObj
.Top = 14
.Left = 119
.Width = chartAreaObj.Width - 120
.Height = chartAreaObj.Height - 6
ActiveSheet.Range("A1").Activate
End With
With legendObj
.Border.LineStyle = xlNone
.AutoScaleFont = False
.Width = 131
.Height = chartAreaObj.Height - 2
.Top = 0
.Left = 0
.Font.Size = 12
End With
Bookmarks