Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a VB.NET Expert!

Join 416,720 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,850 people online right now.Registration is fast and FREE... Join Now!



Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

Copy from Excel to Power Point Rate Topic: -----

#1 ysharb  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-November 08


Dream Kudos: 0

Share |

Copy from Excel to Power Point

Posted 19 November 2008 - 03:46 PM

Dear Members,

How do I copy data from excel to a power point slide using virtual basic. The idea is to generate automatic profile slides from excel data. I found some code on how to copy chart objects but not data.

so for example

Name: Yosef
Age: 22
Education: Engineering
Attached picture.

This needs to go onto a slide with a certain font and position. In addition to the attached foto.

Thanks in advance,
Yosef


try
	' Create an instance of PowerPoint.
	powerpointApplication = _
		New Microsoft.Office.Interop.PowerPoint.ApplicationClass()

	' Create an instance Excel.		  
	excelApplication = _
		New Microsoft.Office.Interop.Excel.ApplicationClass()

	' Open the Excel workbook containing the worksheet with the chart data.
	excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath)

	' Get the worksheet that contains the chart.
	targetSheet = excelWorkBook.Worksheets("Quarterly Sales")

	' Get the ChartObjects collection for the sheet.
	ChartObjects = targetSheet.ChartObjects()

	' Get the chart to copy.
	existingChartObject = ChartObjects.Item("Sales Chart")

	' Create a PowerPoint presentation.
	pptPresentation = powerpointApplication.Presentations.Add()

	' Add a blank slide to the presentation.
	pptSlide = _
		pptPresentation.Slides.Add(1, pptNS.PpSlideLayout.ppLayoutBlank)

	' Copy the chart from the Excel worksheet to the clipboard.
	existingChartObject.Copy()

	' Paste the chart into the PowerPoint presentation.
	shapeRange = pptSlide.Shapes.Paste()

	' Position the chart on the slide.
	shapeRange.Left = 60
	shapeRange.Top = 100

	' Save the presentation.
	pptPresentation.SaveAs(paramPresentationPath)
Catch ex As Exception
	Console.WriteLine(ex.Message)
Finally
	' Release the PowerPoint slide object.
	shapeRange = Nothing
	pptSlide = Nothing

	' Close and release the Presentation object.
	If Not pptPresentation Is Nothing Then
		pptPresentation.Close()
		pptPresentation = Nothing
	End If

	' Quit PowerPoint and release the ApplicationClass object.
	If Not powerpointApplication Is Nothing Then
		powerpointApplication.Quit()
		powerpointApplication = Nothing
	End If

	' Release the Excel objects.
	targetSheet = Nothing
	ChartObjects = Nothing
	existingChartObject = Nothing

	' Close and release the Excel Workbook object.
	If Not excelWorkBook Is Nothing Then
		excelWorkBook.Close(False)
		excelWorkBook = Nothing
	End If

	' Quit Excel and release the ApplicationClass object.
	If Not excelApplication Is Nothing Then
		excelApplication.Quit()
		excelApplication = Nothing
	End If

	GC.Collect()
	GC.WaitForPendingFinalizers()
	GC.Collect()
	GC.WaitForPendingFinalizers()
End Try

Was This Post Helpful? 0
  • +
  • -


#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • Icon

Reputation: 1401
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07


Dream Kudos: 12950

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

Re: Copy from Excel to Power Point

Posted 19 November 2008 - 07:02 PM

This is VB.NET code, moved to the VB.NET forum :)
Was This Post Helpful? 1

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users