|
-
May 6th, 2005, 10:48 AM
#1
Thread Starter
New Member
Excel charts and macro problem
Hi,
I'm able to run my macro perfectly well in the workbook that the macro is contained in. However, when I try to run it in another workbook, the macro does not run. I get a:
Run-time error '1004'
Unable to get the Chart Objects property of the Worksheet class
This is the line highlighted:
ActiveSheet.ChartObjects("Chart 2").Activate
Here is the bunch of code that contains that line:
ActiveChart.Axes(xlValue).Select
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
ActiveWindow.Visible = False
Windows("nmmacrosheet.xls").Activate
Range("A26").Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveWindow.Visible = False
Selection.Delete
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Delete
ActiveChart.SeriesCollection(1).XValues = "=graphs!R2C10:R361C10"
ActiveChart.SeriesCollection(2).XValues = "=graphs!R2C10:R361C10"
I'd appreciate help with this. I'm guessing that it has to do something with the chart and the workbook.
Thanks,
Neil
-
May 6th, 2005, 11:55 AM
#2
Re: Excel charts and macro problem
You try to run it in another workbook, does the other workbook contain the macro code in "ITS" ThisWorkbook class?
If its not in the workbook that your trying to run the macro then it cant see it. Maybe you want to place the macro in your personal
macro workbook?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 6th, 2005, 02:08 PM
#3
Addicted Member
Re: Excel charts and macro problem
what Robb said, or your worksheet does not contain a 'Chart 2' object
if you fail to plan, you plan to fail
-
May 7th, 2005, 08:33 AM
#4
Thread Starter
New Member
Re: Excel charts and macro problem
Hi,
Thanks for the advice and I am asking for further.
When I try to use the personal macro workbook, I get a message:
Cannot edit a macro in a hidden workbook. Unhide the workbook using the Unhide command.
However, I can't even find that workbook.
Also, is there a way to define the other workbook so that I can have the macro go to that one rather than looking for the workbook that I wrote the macro within? Basically, I am taking a bunch of data from a measurement device which yields an unformatted Excel workbook. The macro that I am writing is supposed to format the sheets into something useable including graphs.
Thanks again,
Neil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|