|
-
Dec 19th, 2010, 06:01 PM
#1
[RESOLVED] Exporting Image From Excel
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
-
Dec 19th, 2010, 07:04 PM
#2
Re: Exporting Image From Excel
Excel ChartObject does not have a Paste property. Try myChart.Chart.Paste() instead.
There is also an error in the immediate next line and that needs to be corrected too.
Code:
myChart.Chart.Paste()
myChart.Chart.Export("C:\Temp\Image" & I & ".gif", "GIF", True)
-
Dec 19th, 2010, 07:15 PM
#3
Re: Exporting Image From Excel
Try this code. It will also delete the unwanted image as required in your comments:
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xlApp As Excel.Application Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet Dim olobj As Excel.Shape Dim xlCharts As Excel.ChartObjects Dim myChart As Excel.ChartObject Dim I As Long = 1 xlApp = New Excel.ApplicationClass xlWorkBook = xlApp.Workbooks.Open("C:\Temp\Test.xlsx") xlWorkSheet = xlWorkBook.Worksheets("Sheet1") xlCharts = xlWorkSheet.ChartObjects 'myChart = xlCharts.Add(10, 80, 300, 250) '<~~ There could be more pictures than one For Each olobj In xlWorkSheet.Shapes myChart = xlCharts.Add(10, 80, 300, 250) olobj.Copy() myChart.Activate() myChart.Chart.Paste() myChart.Chart.Export("C:\Temp\Image" & I & ".gif", "GIF", True) I = I + 1 myChart.Delete() Next xlWorkBook.Close(SaveChanges:=False) xlApp.Quit() releaseObject(xlApp) releaseObject(xlWorkBook) releaseObject(xlWorkSheet) End Sub
-
Dec 19th, 2010, 07:18 PM
#4
Re: Exporting Image From Excel
Simply Superb!!!!! 
I was trying to think what to do to get the initial image off the chart...
Works flawlessly! I knew I could always count on you when it came to vb.net!
Thanks again...
Sid
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
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
|