|
-
Aug 11th, 2010, 03:20 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] How to select/copy a chart in a chart sheet
Hello.
I’ve been working on a project, and had fantastic success with the search feature the last few days – I was able to find answers for everything I was looking for (and I even gave good rep to the people that posted the answers I was looking for). But now I’m stuck, and I need a little help.
I have an Excel file that I’m working with via .NET. One of the tabs is a chart – which I understand is actually a chart sheet (the entire tab is a big chart, with no cells).
I can open the Excel file:
Code:
Dim xExcelApp As New Excel.Application
xExcelApp.Workbooks.Open("C:\test.xls")
My problem is with the chart sheet. I want to select the chart, and then copy it (so I can paste it somewhere else). No matter what I try, I can’t seem to select the chart in the chart sheet:
Code:
xExcelApp.Workbooks(1).Worksheets("Report4_Chart").select()
xExcelApp.Selection.Copy()
Any ideas on what I’m doing wrong?
.
~Peter

-
Aug 11th, 2010, 03:31 PM
#2
Re: How to select/copy a chart in a chart sheet
I don't have vb.net so try this for me...
Code:
xExcelApp.Workbooks(1).sheets("Report4_Chart").ChartArea.Copy
or try this
Code:
xExcelApp.Workbooks(1).sheets("Report4_Chart").ChartArea.Copy()
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Aug 12th, 2010, 07:09 AM
#3
Re: How to select/copy a chart in a chart sheet
To make it clear on these 3 object collections in a workbook:
- Worksheets: contains all worksheets: each member is a Worksheet object
- Charts: contains all chart sheets: each member is a Chart object
- Sheets: contains all worksheets and chart sheets: each member is either a Worksheet object or a Chart object. Noted that there is no Sheet object.
A Chart object (chart sheet) is a member of Charts collection and it is also a member of Sheets collection.
A Worksheet object is a member of Worksheets collection and it is also a member of Sheets collection.
To specify a chart sheet, you cannot use Worksheets(index) but you have to use:
Charts(index)
or
Sheets(index)
where index is index-number or name.
In your case, you can use either:
xExcelApp.Workbooks(1).Charts("Report4_Chart").ChartArea.Copy
or
xExcelApp.Workbooks(1).Sheets("Report4_Chart").ChartArea.Copy
-
Aug 12th, 2010, 09:16 AM
#4
Thread Starter
Frenzied Member
Re: How to select/copy a chart in a chart sheet
Thanks for all the help. I was able to get it to work with:
xExcelApp.Workbooks(1).Charts("Report4_Chart").ChartArea.Copy
It's such a simple solution. Excellent. Thank you.
.
~Peter

Tags for this Thread
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
|