[英]Open Power Point chart data in Excel
I'm trying to create a macro to clean up the Excel sheets behind charts in power point so that only the data being used in the chart is there, and there are no formulas. 我正在尝试创建一个宏以清理Powerpoint中图表后面的Excel工作表,以便仅存在图表中正在使用的数据,并且没有公式。
I've pieced together this, which works when I open the chart data in Excel, but I'm hoping I can create a macro that cycles through each chart in the workbook and opens the chart data in Excel for me, so I can perform the following on each. 我拼凑了一下,当我在Excel中打开图表数据时可以正常工作,但是我希望可以创建一个宏来遍历工作簿中的每个图表,并为我打开Excel中的图表数据,以便我可以执行每个以下。
Sub ChartCleaningPP()
'Paste values of table
Range("Table1[#All]").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Dim Cell As Range
'clear other cells
For Each Cell In ActiveSheet.UsedRange
If Intersect(Cell, Selection) Is Nothing Then
Cell.Clear
End If
Next Cell
'remove hidden
For lp = 256 To 1 Step -1
If Columns(lp).EntireColumn.Hidden = True Then Columns(lp).EntireColumn.Delete Else
Next
For lp = 65536 To 1 Step -1
If Rows(lp).EntireRow.Hidden = True Then Rows(lp).EntireRow.Delete Else
Next
'close window
ActiveWindow.Close
End Sub
Try this: 尝试这个:
Sub ChangeCharts()
Dim ws As Worksheet
Dim myChart As ChartObject
For Each ws In ThisWorkbook.Worksheets
For Each myChart In ws.ChartObjects
'your code here
'i.e Call ChartCleaningPP
Next myChart
Next ws
End Sub
EDIT: (Run Excel Makro from PP) Need to activate MS Excel Libraries in PP. 编辑:(从PP运行Excel Makro)需要在PP中激活MS Excel库。
Sub RunExcelMakro()
Dim wk As Object
Dim Path As String
CreateObject ("Excel.Application")
Set xlApp = New Excel.Application
xlApp.Visible = True
Path = "C:\Users\User\Desktop\F\1.xlsm" 'Edit Path
Set wk = xlApp.Workbooks.Open(Path)
xlApp.Run "YourMakro"
xlApp.Quit
End Sub
EDIT: 编辑:
Sub M1()
Dim sld As Slide
Dim sh As Shape
Dim Path As String
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.Type = msoLinkedOLEObject Then
With sh.LinkFormat
Path = .SourceFullName
xlApp.Workbooks.Open Path
End With
End If
Next sh
Next sld
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.