|
楼主 |
发表于 2023-3-28 13:30
|
显示全部楼层
- ''
- Sub ll2()
- Dim Pres As Presentation
- Dim Sld As Slide, ShpRng As ShapeRange
- Dim Arr1, Arr2
- Dim xChart As Chart
- Dim oTab As Table
- Dim Txt As TextFrame
- Dim TxtRng As TextRange
- Dim Ww As Workbook
- Dim Nn, Str
- ''
- Dim Sht As Worksheet
- Dim Rng As Range
- Dim ii, jj
- Dim Arr(7)
- Set Pres = Application.ActivePresentation
- Set Sld = Pres.Slides(1)
- Set xChart = Sld.Shapes("C1").Chart
- Set oTab = Sld.Shapes("T1").Table
- Set Txt = Sld.Shapes("N1").TextFrame
- Set TxtRng = Txt.TextRange
- ''
- With xChart
- For ii = .SeriesCollection.Count To 1 Step -1
- .SeriesCollection(ii).Delete
- Next ii
- .ChartData.Activate
- 'Stop
- Set Sht = .ChartData.Workbook.Worksheets(1)
- Set Rng = Sht.Range("a1:i4")
- .SetSourceData "=" & Sht.Name & "!" & Rng.Address, xlRows
- .HasDataTable = True
- .HasLegend = False
- '.DataTable.Font.Size = 10
- '.Axes(xlValue).Select
- 'ActiveWindow.Selection.TextRange.Font.Size = 9
- 'Selection.TickLabels.Font.Size = 10
- '.Axes(xlValue, xlSecondary).Select
- 'Selection.TickLabels.Font.Size = 10
- For ii = 1 To 3
- Select Case ii
- Case 1, 2
- .SeriesCollection(ii).ChartType = xlColumnClustered 'xlColumnStacked
- Case 3, 4
- .SeriesCollection(ii).ChartType = xlLine
- .SeriesCollection(ii).AxisGroup = 2
- End Select
- Next ii
- '
- With oTab
-
- For ii = 1 To 3
- Select Case ii
- Case 2, 3
- '.Cell(ii, 1).Shape.TextFrame2.TextRange.Text = Sht.Cells(ii, 1) & "时间差"
- Case 5, 4
- '.Cell(ii, 1).Shape.TextFrame2.TextRange.Text = Sht.Cells(ii, 1) & "温度差"
- End Select
- .Rows(ii).Height = 25
- Next ii
- For jj = 3 To 9
- .Cell(1, jj - 2).Shape.TextFrame2.TextRange.Text = Sht.Cells(1, jj) & "-" & Sht.Cells(1, 2)
- Next jj
- ''
- For ii = 2 To 5
- For jj = 3 To 9
- 'Nn = Sht.Cells(ii, jj) - Sht.Cells(ii, 2)
- 'Str = Format(Abs(Nn), "h""时""m""分"";@")
- Str = Format(Abs(Sht.Cells(ii, jj) - Sht.Cells(ii, 2)), "h:m")
- Nn = Split(Str, ":")
- Str = Nn(0) * 60 + Nn(1) & "分"
-
-
-
- Select Case ii
- Case 2, 3
- '.Cell(ii, jj - 2).Shape.TextFrame2.TextRange.Text = Format(Sht.Cells(ii, jj), "h:mm") & "-" & Format(Sht.Cells(ii, 2), "h:mm") & _
- "=" & vbCr & Sht.Cells(ii, 1) & "时差" & Format(Abs(Nn), "h:mm")
- .Cell(ii, jj - 2).Shape.TextFrame2.TextRange.Text = Sht.Cells(ii, 1) & "时差" & Str & _
- vbCr & "(" & Format(Sht.Cells(ii, jj), "h:mm") & "-" & Format(Sht.Cells(ii, 2), "h:mm") & "=" & Format(Abs(Sht.Cells(ii, jj) - Sht.Cells(ii, 2)), "h:mm") & ")"
- 'Str = .Cell(ii, jj - 2).Shape.TextFrame2.TextRange.Characters(5, 4)
- With .Cell(ii, jj - 2).Shape.TextFrame.TextRange.Characters(5, 4)
- .Font.Color = -16776961
- .Font.Size = 20
- End With
- 'Debug.Print Str
-
-
- Case 5, 4
- '.Cell(ii, jj - 2).Shape.TextFrame2.TextRange.Text = Sht.Cells(ii, jj) & "-" & Sht.Cells(ii, 2) & _
- "=" & Sht.Cells(ii, 1) & "温差" & Nn & "C"
- '.Cell(ii, jj - 2).Shape.TextFrame2.TextRange.Text = Sht.Cells(ii, 1) & "温差" & Sht.Cells(ii, jj) - Sht.Cells(ii, 2) & "℃"
-
- End Select
-
- Next jj
- Next ii
- End With
- End With
- For ii = 16 To 24
- Str = Sht.Cells(ii, 1)
- Set Shp = Sld.Shapes(Str)
- Set TxtRng2 = Shp.TextFrame2.TextRange
- TxtRng2.Text = Sht.Cells(ii, 2)
- Debug.Print Shp.Name, Shp.Type, TxtRng2.Text
- Next ii
- End Sub
- ''
- Sub ll3()
- Dim Pres As Presentation
- Dim xChart As Chart
- Dim xlWk As Workbook
- Dim Sht As Worksheet
- Dim Rng As Range
- Dim Str
- Set Pres = Application.ActivePresentation
- Set xChart = Pres.Slides(1).Shapes("C1").Chart
- ''
- xChart.ChartData.Activate
- Set xlWk = xChart.ChartData.Workbook
- Set Sht = xlWk.Worksheets(1)
- Set Rng = Sht.Range("B1:I4")
-
- Dim Shp As Shape, Kk
- Dim Sld As Slide, oSld As Slide
- Dim SldArr() As Slide
- ReDim SldArr(1 To Rng.Columns.Count) As Slide
- Dim ShpRng As ShapeRange
- Dim TxtRng As TextRange
- Set Sld = Pres.Slides(1)
- ''
- For ii = 16 To 24
- Str = Sht.Cells(ii, 1)
- Set Shp = Sld.Shapes(Str)
- Set TxtRng = Shp.TextFrame.TextRange
- With TxtRng
- .Text = Sht.Cells(ii, 2)
- .Font.Color = -16776961
- .Characters(Sht.Cells(ii, 3), Sht.Cells(ii, 4)).Font.Color = 0
- End With
- Next ii
-
- ''
- For ii = Pres.Slides.Count To 2 Step -1
- Set oSld = Pres.Slides(ii)
- oSld.Delete
- Next ii
- For jj = 2 To Rng.Columns.Count
- Sld.Duplicate
- Next jj
- For jj = 1 To Rng.Columns.Count
- Set SldArr(jj) = Pres.Slides(jj)
- SldArr(jj).Name = Rng(1, jj).Value
- Next jj
- ChangeChartNoteData Rng, SldArr
- xlWk.Close
- End Sub
- Function ChangeChartNoteData(Rng As Range, SldArr)
- Dim ii, jj
- Dim oRng As Range
- Dim Sld As Slide
- For jj = 2 To Rng.Columns.Count
- Set Sld = SldArr(jj)
- ExchangeRng Sld, Rng, jj
- Next jj
- End Function
- Function ExchangeRng(Sld As Slide, Rng As Range, Cc)
- Dim ii, jj, Ccc, Str
- Dim xChart As Chart
- Dim Sht As Worksheet
- Dim tmpRng As Range
- Dim oRng As Range
- Dim xlWk As Workbook
- Dim TxtRng As TextRange
- Set xChart = Sld.Shapes("C1").Chart ''
- xChart.ChartData.Activate
- Set xlWk = xChart.ChartData.Workbook
- Set Sht = xlWk.Worksheets(1)
- Set oRng = Sht.Range("B1:I4")
-
- For jj = Cc To Rng.Columns.Count
- For ii = 1 To Rng.Rows.Count
- Ccc = jj - Cc + 1
- oRng(ii, Ccc) = Rng(ii, jj)
- Next ii
- Next jj
- ''
- For jj = 1 To Cc - 1
- For ii = 1 To Rng.Rows.Count
- Debug.Print oRng(ii, Ccc + jj).Address, Rng(ii, jj).Address
- oRng(ii, jj + Ccc) = Rng(ii, jj)
- Next ii
- Next jj
- For ii = 16 To 24
- Str = Sht.Cells(ii, 1)
- Set Shp = Sld.Shapes(Str)
- Set TxtRng = Shp.TextFrame.TextRange
- With TxtRng
- .Text = Sht.Cells(ii, 2)
- .Font.Color = -16776961
- .Characters(Sht.Cells(ii, 3), Sht.Cells(ii, 4)).Font.Color = 0
- End With
- Next ii
-
- ''
- xChart.ChartData.BreakLink
- xlWk.Close
-
- End Function
复制代码
|
|