Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Method 'Location' of Object'_Chart' failed


Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2003, 01:52 PM
galbre galbre is offline
Newcomer
 
Join Date: Mar 2003
Posts: 19
Question Method 'Location' of Object'_Chart' failed


Hello, Maybe somebody ran into this error and knows a solution. I am writing data to excel and then I plot it. This works fine. I then try to run the same routine again on a new excel sheet (I even close the other sheet) and that is when I get the following error.

Run-time Error '1004'
Method 'Location' of Object'_Chart' failed

Here is how I create the excel application:
---------------------------------------------------

Set oExcel = New Excel.Application
oExcel.Visible = True 'make Excel visible to the user
'open up a template sheet stored in the string variable "template"
oExcel.Workbooks.Open filename:=template
filepath = "C:\"
filename = "UnitNo_" & & "_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & "_" & Hour(Time) & "_" & Minute(Time) & ".xls" oExcel.ActiveWorkbook.SaveAs filename:=filepath & filename
Set xlSh = oExcel.Workbooks(1).Worksheets(1)
---------------------------------------------------

Here is where I get the error msg while plotting (error occurs on the last line):
---------------------------------------------------
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("raw data").Range("K154")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='raw data'!R197C1:R223C1"
ActiveChart.SeriesCollection(1).Values = "='raw data'!R197C2:R223C2"
ActiveChart.SeriesCollection(1).Name = "='raw data'!R196C2"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"plot1"
---------------------------------------------------

If I quit my program and restart it I don't get the error. So I looked at what I do when ending my program which is:

Set oExcel = Nothing
Set xlSh = Nothing

I tried adding that to the end of my plotting routine (to try to mimic what happens when I quit and restart but of course that doesn't work.

Quitting and restarting is annoying because I do a lot of setup stuff in the beginning that I would like to avoid redoing if I could. Does anyone know what I am doing wrong?
Thanks for any help.
Gregg
Reply With Quote
  #2  
Old 06-17-2003, 02:06 PM
Granty Granty is offline
Junior Contributor
 
Join Date: Oct 2002
Location: London
Posts: 290
Default

Quote:
Originally Posted by galbre
Hello, Maybe somebody ran into this error and knows a solution. I am writing data to excel and then I plot it. This works fine. I then try to run the same routine again on a new excel sheet (I even close the other sheet) and that is when I get the following error.

Run-time Error '1004'
Method 'Location' of Object'_Chart' failed

Here is how I create the excel application:
---------------------------------------------------

Set oExcel = New Excel.Application
oExcel.Visible = True 'make Excel visible to the user
'open up a template sheet stored in the string variable "template"
oExcel.Workbooks.Open filename:=template
filepath = "C:\"
filename = "UnitNo_" & & "_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & "_" & Hour(Time) & "_" & Minute(Time) & ".xls" oExcel.ActiveWorkbook.SaveAs filename:=filepath & filename
Set xlSh = oExcel.Workbooks(1).Worksheets(1)
---------------------------------------------------

Here is where I get the error msg while plotting (error occurs on the last line):
---------------------------------------------------
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("raw data").Range("K154")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='raw data'!R197C1:R223C1"
ActiveChart.SeriesCollection(1).Values = "='raw data'!R197C2:R223C2"
ActiveChart.SeriesCollection(1).Name = "='raw data'!R196C2"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"plot1"
---------------------------------------------------

If I quit my program and restart it I don't get the error. So I looked at what I do when ending my program which is:

Set oExcel = Nothing
Set xlSh = Nothing

I tried adding that to the end of my plotting routine (to try to mimic what happens when I quit and restart but of course that doesn't work.

Quitting and restarting is annoying because I do a lot of setup stuff in the beginning that I would like to avoid redoing if I could. Does anyone know what I am doing wrong?
Thanks for any help.
Gregg



Think you will need an oExcel.Quit in your termination bit.
Reply With Quote
  #3  
Old 06-17-2003, 02:07 PM
Granty Granty is offline
Junior Contributor
 
Join Date: Oct 2002
Location: London
Posts: 290
Default

Quote:
Originally Posted by galbre
Hello, Maybe somebody ran into this error and knows a solution. I am writing data to excel and then I plot it. This works fine. I then try to run the same routine again on a new excel sheet (I even close the other sheet) and that is when I get the following error.

Run-time Error '1004'
Method 'Location' of Object'_Chart' failed

Here is how I create the excel application:
---------------------------------------------------

Set oExcel = New Excel.Application
oExcel.Visible = True 'make Excel visible to the user
'open up a template sheet stored in the string variable "template"
oExcel.Workbooks.Open filename:=template
filepath = "C:\"
filename = "UnitNo_" & & "_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & "_" & Hour(Time) & "_" & Minute(Time) & ".xls" oExcel.ActiveWorkbook.SaveAs filename:=filepath & filename
Set xlSh = oExcel.Workbooks(1).Worksheets(1)
---------------------------------------------------

Here is where I get the error msg while plotting (error occurs on the last line):
---------------------------------------------------
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("raw data").Range("K154")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='raw data'!R197C1:R223C1"
ActiveChart.SeriesCollection(1).Values = "='raw data'!R197C2:R223C2"
ActiveChart.SeriesCollection(1).Name = "='raw data'!R196C2"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"plot1"
---------------------------------------------------

If I quit my program and restart it I don't get the error. So I looked at what I do when ending my program which is:

Set oExcel = Nothing
Set xlSh = Nothing

I tried adding that to the end of my plotting routine (to try to mimic what happens when I quit and restart but of course that doesn't work.

Quitting and restarting is annoying because I do a lot of setup stuff in the beginning that I would like to avoid redoing if I could. Does anyone know what I am doing wrong?
Thanks for any help.
Gregg




Think you will need an oExcel.Quit in your termination bit.
Reply With Quote
  #4  
Old 06-17-2003, 02:08 PM
Granty Granty is offline
Junior Contributor
 
Join Date: Oct 2002
Location: London
Posts: 290
Default

Think you will need an oExcel.Quit in your termination bit.
Reply With Quote
  #5  
Old 06-18-2003, 01:52 AM
Granty Granty is offline
Junior Contributor
 
Join Date: Oct 2002
Location: London
Posts: 290
Default

Sorry for spam, stupid thing was telling me my send failed each time
Reply With Quote
  #6  
Old 06-20-2003, 03:58 PM
galbre galbre is offline
Newcomer
 
Join Date: Mar 2003
Posts: 19
Default

I will give it a shot and let you know what happens. Thanks!
Reply With Quote
  #7  
Old 08-13-2003, 12:46 AM
sureshbabu sureshbabu is offline
Newcomer
 
Join Date: Apr 2003
Posts: 2
Unhappy Run-time Error '1004' Method 'Location' of Object'_Chart' failed

Quote:
Originally Posted by Granty
Quote:
Originally Posted by galbre
Hello, Maybe somebody ran into this error and knows a solution. I am writing data to excel and then I plot it. This works fine. I then try to run the same routine again on a new excel sheet (I even close the other sheet) and that is when I get the following error.

Run-time Error '1004'
Method 'Location' of Object'_Chart' failed

Here is how I create the excel application:
---------------------------------------------------

Set oExcel = New Excel.Application
oExcel.Visible = True 'make Excel visible to the user
'open up a template sheet stored in the string variable "template"
oExcel.Workbooks.Open filename:=template
filepath = "C:\"
filename = "UnitNo_" & & "_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & "_" & Hour(Time) & "_" & Minute(Time) & ".xls" oExcel.ActiveWorkbook.SaveAs filename:=filepath & filename
Set xlSh = oExcel.Workbooks(1).Worksheets(1)
---------------------------------------------------

Here is where I get the error msg while plotting (error occurs on the last line):
---------------------------------------------------
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("raw data").Range("K154")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='raw data'!R197C1:R223C1"
ActiveChart.SeriesCollection(1).Values = "='raw data'!R197C2:R223C2"
ActiveChart.SeriesCollection(1).Name = "='raw data'!R196C2"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"plot1"
---------------------------------------------------

If I quit my program and restart it I don't get the error. So I looked at what I do when ending my program which is:

Set oExcel = Nothing
Set xlSh = Nothing

I tried adding that to the end of my plotting routine (to try to mimic what happens when I quit and restart but of course that doesn't work.

Quitting and restarting is annoying because I do a lot of setup stuff in the beginning that I would like to avoid redoing if I could. Does anyone know what I am doing wrong?
Thanks for any help.
Gregg




same message haunting me also

any help

welcome

suresh
Think you will need an oExcel.Quit in your termination bit.

Reply With Quote
  #8  
Old 09-05-2003, 09:35 AM
galbre galbre is offline
Newcomer
 
Join Date: Mar 2003
Posts: 19
Default

Quote:
Originally Posted by sureshbabu
Quote:
Originally Posted by Granty
Quote:
Originally Posted by galbre
Hello, Maybe somebody ran into this error and knows a solution. I am writing data to excel and then I plot it. This works fine. I then try to run the same routine again on a new excel sheet (I even close the other sheet) and that is when I get the following error.

Run-time Error '1004'
Method 'Location' of Object'_Chart' failed

Here is how I create the excel application:
---------------------------------------------------

Set oExcel = New Excel.Application
oExcel.Visible = True 'make Excel visible to the user
'open up a template sheet stored in the string variable "template"
oExcel.Workbooks.Open filename:=template
filepath = "C:\"
filename = "UnitNo_" & & "_" & Month(Date) & "_" & Day(Date) & "_" & Year(Date) & "_" & Hour(Time) & "_" & Minute(Time) & ".xls" oExcel.ActiveWorkbook.SaveAs filename:=filepath & filename
Set xlSh = oExcel.Workbooks(1).Worksheets(1)
---------------------------------------------------

Here is where I get the error msg while plotting (error occurs on the last line):
---------------------------------------------------
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("raw data").Range("K154")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='raw data'!R197C1:R223C1"
ActiveChart.SeriesCollection(1).Values = "='raw data'!R197C2:R223C2"
ActiveChart.SeriesCollection(1).Name = "='raw data'!R196C2"
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"plot1"
---------------------------------------------------

If I quit my program and restart it I don't get the error. So I looked at what I do when ending my program which is:

Set oExcel = Nothing
Set xlSh = Nothing

I tried adding that to the end of my plotting routine (to try to mimic what happens when I quit and restart but of course that doesn't work.

Quitting and restarting is annoying because I do a lot of setup stuff in the beginning that I would like to avoid redoing if I could. Does anyone know what I am doing wrong?
Thanks for any help.
Gregg




same message haunting me also

any help

welcome

suresh
Think you will need an oExcel.Quit in your termination bit.





Thanks Suresh. I got away from it for a while but now I need to solve it. I tried adding oExcel.quit but still no luck. I haven't given up. It works fine on the second sheet (you can place data into cells) but the minute I try to plot, that's when I get the run-time error.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Method 'Open of object recordset' failed dgdolins1 Database and Reporting 2 02-29-2004 04:20 AM
Getting Method "Cells" of object"_Global" failed?? oldweasel Excel 2 04-29-2003 06:30 PM
Method Failed MacroMan Excel 5 04-11-2003 07:36 AM
Urgent : method '~' of '~' failed lindts Installation / Documentation 1 11-21-2002 12:18 PM
'Method "Range" of object "_Global" failed.' ??? Echo15 Word, PowerPoint, Outlook, and Other Office Products 1 11-17-2002 11:40 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->