V
vic
Hi,
I'm creating Excel spreadsheets within an Access application. When the
following code was all in the same Sub, it worked.
Set xlApp = CreateObject("Excel.Application")
Set xlWrkbk = xlApp.Workbooks.Open(FileLocation)
Set xlChartObj = xlApp.Charts.Add
xlWrkbk.ActiveChart.ChartType = xlPie
xlWrkbk.ActiveChart.SetSourceData Source:=xlSourceRange,
PlotBy:=xlColumns
xlWrkbk.ActiveChart.Location Where:=xlLocationAsObject,
name:=ChartSheetName
xlWrkbk.ActiveChart.HasTitle = True
xlWrkbk.ActiveChart.PlotArea.Height = PlotAreaSize
xlWrkbk.ActiveChart.PlotArea.Width = PlotAreaSize
But, when I moved the top two lines (Set xlApp and Set xlWrkbk) to a
different procedure, and passed the xlApp and xlWrkbk as parameters to
the original procedure, I start getting errors. Error is: "1004,
Method 'HasTitle' of object '_Chart' failed". The next error is:
"1004, Unable to get the Height property of the PlotArea class."
When passing the Excel objects as variables, I'm using ByRef xlApp as
Excel.Application.
Any ideas what I'm doing wrong here.
Thanks,
Vic
I'm creating Excel spreadsheets within an Access application. When the
following code was all in the same Sub, it worked.
Set xlApp = CreateObject("Excel.Application")
Set xlWrkbk = xlApp.Workbooks.Open(FileLocation)
Set xlChartObj = xlApp.Charts.Add
xlWrkbk.ActiveChart.ChartType = xlPie
xlWrkbk.ActiveChart.SetSourceData Source:=xlSourceRange,
PlotBy:=xlColumns
xlWrkbk.ActiveChart.Location Where:=xlLocationAsObject,
name:=ChartSheetName
xlWrkbk.ActiveChart.HasTitle = True
xlWrkbk.ActiveChart.PlotArea.Height = PlotAreaSize
xlWrkbk.ActiveChart.PlotArea.Width = PlotAreaSize
But, when I moved the top two lines (Set xlApp and Set xlWrkbk) to a
different procedure, and passed the xlApp and xlWrkbk as parameters to
the original procedure, I start getting errors. Error is: "1004,
Method 'HasTitle' of object '_Chart' failed". The next error is:
"1004, Unable to get the Height property of the PlotArea class."
When passing the Excel objects as variables, I'm using ByRef xlApp as
Excel.Application.
Any ideas what I'm doing wrong here.
Thanks,
Vic