Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
does anyone know the code to insert a large number of linked chart from excel into powerpoint? I have worked out how to export unlinked pictures from excel and a almost there in PP by copy/pastespecial linking a single linked chart copying it to a new slide, and overwriting the source, but I'd like t automate the whole process if possible. My problem is that in PP there seems to be neither a pastespecia command nor any means of indicating which chart from a workbook t display through the insert object method. Am I misisng something obvious here -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nicky,
Does this help? The macro assumes that the Excel workbook has the same name as the P file, except for the file extension. The "Chart_Array" lists the names of the Excel worksheets, each o which contains a chart. Each charts is then copied as a 'picture'. Sub Import_Excel_Chart() Dim Path_Name As String Dim Last_Slide As Integer Dim Slide_Index As Integer Dim Chart_Array As Variant Dim Chart_Value As Variant Dim PP_App As PowerPoint.Application Dim PP_Pres As PowerPoint.Presentation Dim PP_Pres_Name As String Dim PP_Slide As PowerPoint.Slide Dim Excel_App As Excel.Application Dim Excel_Book As Excel.Workbook Dim Excel_Chart As Excel.Chart On Error GoTo ERROR_HANDLER Path_Name = CurDir & "\" PP_Pres_Name = Left(ActivePresentation.Name Len(ActivePresentation.Name) - 4) Set PP_App = PowerPoint.Application Set PP_Pres = PP_App.ActivePresentation Last_Slide = PP_Pres.Slides.Count If Last_Slide 0 Then For Slide_Index = 1 To Last_Slide ActiveWindow.Selection.SlideRange.Delete Next Slide_Index End If Set Excel_App = Nothing Set Excel_App = New Excel.Application Excel_App.Application.Visible = False Excel_App.Application.DisplayAlerts = False Set Excel_Book = Excel_App.Workbooks.Open _ (Path_Name & PP_Pres_Name & ".xls") Chart_Array = Array("OUTSTANDING_TRANSACTIONS", _ "OUTSTANDING_AMOUNTS", _ "AGED_RECORDS", _ "AGED_RECORDS_(with Total)", _ "AGED_RECORDS_(stacked)", _ "AGED_RECORDS_(stacked_100)", _ "AGED_RECORDS_(by Date)", _ "AGED_RECORDS_(by Date)_3D") Slide_Index = 0 For Each Chart_Value In Chart_Array Slide_Index = Slide_Index + 1 ActiveWindow.View.GotoSlid Index:=ActivePresentation.Slides.Add _ (Index:=Slide_Index, Layout:=ppLayoutBlank).SlideIndex Set PP_Slide = PP_Pres.Slides _ (PP_App.ActiveWindow.Selection.SlideRange.SlideInd ex) COPY_CHART: Excel_App.Charts(Chart_Value).CopyPicture Appearance:=xlScreen Format:=xlPicture PP_Slide.Shapes.Paste.Select PP_App.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters True PP_App.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles True With ActiveWindow.Selection.ShapeRange .Height = 414.88 .Width = 718.62 .Left = 0.75 .Top = 35 End With ActiveWindow.Selection.Unselect Next ActiveWindow.View.GotoSlide (1) GoTo ENDSUB ERROR_HANDLER: Msg = "Error occurred during copy process." & Chr(10) Msg = Msg + " " & Chr(10) Msg = Msg + "Re-run macro." & Chr(10) Msg = Msg + " " & Chr(10) Msg = Msg + "Process terminated." & Chr(10) Msg = Msg + " " Style = vbOKOnly Response = MsgBox(Msg, Style, Title) ENDSUB: Excel_App.Application.DisplayAlerts = False Set Excel_Book = Nothing Set Excel_Chart = Nothing Excel_App.Quit Set Excel_App = Nothing Set PPSlide = Nothing Set PPPres = Nothing Set PPApp = Nothing End Sub Regards, Mark_ -- Message posted from http://www.ExcelForum.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mark,
thanks for that quick response - it works well with a little tweaking. However, what I really wanted was to insert charts that are linked to the excel workbook, for a couple of reasons - it saves overwriting the whole presentation when I only want to update a few charts, and it looks a little better than the copypicture method, which tends to make text and lines a little thicker and more blurred than copy pastespecial links, for some reason. However, if that's not possible, yours will be the next best thing. --- Message posted from http://www.ExcelForum.com/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nicky,
I prefer the above method because I wasn't happy with the formatting i PP. I'm not quite clear on what you've already attempted, but did you tr creating a blank slide, then clicking 'Insert', 'Chart...'? Left-clic somewhere on the slide to close the 'Datasheet' window and make th border around the chart disappear. Then right-click on the displaye chart, point to 'Chart Object' and click 'Open'. On the Microsof Graph menu bar, click 'Edit', 'Import File' and then select the Exce file containing your charts. A window will appear allowing you t select a specific worksheet. Each slide in PP can be linked to different worksheet and will be automatically updated whenever th Excel worksheet changes. Hope this makes sense. Let me know if you have any questions. Regards, Mar -- Message posted from http://www.ExcelForum.com |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Nicky,
I prefer the above method because I wasn't happy with the formatting i PP. I'm not quite clear on what you've already attempted, but did you tr creating a blank slide, then clicking 'Insert', 'Chart...'? Left-clic somewhere on the slide to close the 'Datasheet' window and make th border around the chart disappear. Then right-click on the displaye chart, point to 'Chart Object' and click 'Open'. On the Microsof Graph menu bar, click 'Edit', 'Import File' and then select the Exce file containing your charts. A window will appear allowing you t select a specific worksheet. Each slide in PP can be linked to different worksheet and will be automatically updated whenever th Excel worksheet changes. Hope this makes sense. Let me know if you have any questions. Regards, Mar -- Message posted from http://www.ExcelForum.com |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mark, thanks for that - ther appearance is clearer, though th
formatting needs changing. Still can't either link to the excel sourc file or record/write the code to replicate it though. The nearest I've come is to copy a chart from excel, pastespecia pastelink onto the first slide in powerpoint, then run this code t first copy and then overwrite the linked source for each chart: Sub overwrite_linksources() 'pastelink a chart from the source file onto the first slide 'chart names: charts_array = Array("chart1", "chart2", "chart3", "chart4", "chart5" "chart6") 'source file: file_fullname = "c:\temp\chart source.xls" ActiveWindow.View.GotoSlide Index:=1 ActiveWindow.Selection.SlideRange.Shapes(1).Copy For n = LBound(charts_array) To UBound(charts_array) ActiveWindow.View.GotoSlid Index:=ActivePresentation.Slides.Add(Index:=n + 1 Layout:=ppLayoutBlank).SlideIndex ActiveWindow.View.Paste ActiveWindow.Selection.SlideRange.Shapes(1).LinkFo rmat.SourceFullName file_fullname & "!" & charts_array(n) Next End Su -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
improve clarity of excel data linked in PowerPoint | Excel Discussion (Misc queries) | |||
Gridlines ok in Excel but linked powerpoint- lines are missing | Charts and Charting in Excel | |||
Linked Excel graphs in PowerPoint | Charts and Charting in Excel | |||
How to spread the area of a linked excel worksheet in PowerPoint | Excel Discussion (Misc queries) | |||
How do I insert an Excel file into a PowerPoint Presentation slid. | Excel Discussion (Misc queries) |