Chart position newbie question

K

Keith Wilby

What syntax do I need to position the active chart in a certain position on
a worksheet? I'm doing this from MS Access, here's a code snippet:

With objXL.ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "My Title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Week No"
.Axes(xlValue, xlPrimary).HasTitle = False
End with

This all works nicely but I want to put the chart at certain coordinates on
the sheet. Any clues?

Many thanks.

Keith.
 
M

Mike Fogleman

The Top property can be set to a certain row and the Left property can be
set to a certain column.
With objXL.ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "My Title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Week No"
.Axes(xlValue, xlPrimary).HasTitle = False
.Left = .Columns("B").Left 'left edge of col B
.Top= .Rows(2).Top 'top of row 2
End with

Mike F
 
K

Keith Wilby

Mike Fogleman said:
The Top property can be set to a certain row and the Left property can be
set to a certain column.
With objXL.ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "My Title"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
"Week No"
.Axes(xlValue, xlPrimary).HasTitle = False
.Left = .Columns("B").Left 'left edge of col B
.Top= .Rows(2).Top 'top of row 2
End with

Cheers Mike, just the job.

Keith.
 
J

Jon Peltier

Except you need to position the chart object:

With objXL.ActiveChart
With .Parent
.Left = .Columns("B").Left 'left edge of col B
.Top= .Rows(2).Top 'top of row 2
End With
End with

- Jon
 

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