Problem in graph automation in excel.
Assuming that "ark" is the name on the worksheet tab, change each instance
of Sheets(ark) to Sheets("ark"). The sheet name has to have double quotes
around it. Better yet, use Worksheets("ark").
Also, to simplify, you can factor out Sheets(ark).ChartObjects("Chart
1").Chart.PlotArea on each line and use a With statement instead. Make sure
that there is still a period in each location where this string is removed.
This makes the code much easier to read and maintain. The code will also run
faster, since Excel does not have to perform so many object accesses at
runtime.
pl = Int(chartlengde * 0.05)
ph = Int(charthoyde * 0.7)
pw = Int(chartlengde * 0.9)
With Worksheets("ark").ChartObjects("Chart 1").Chart.PlotArea
.Top = 16
.Left = pl
.Height = ph
.Width = pw
.Interior.ColorIndex = xlNone
pl1 = .Left
pw1 = .Width
ph1 = .Height
End With
--
Regards,
Bill
|