gpt4 book ai didi

excel - 检查当前幻灯片的数量

转载 作者:行者123 更新时间:2023-12-04 21:03:22 25 4
gpt4 key购买 nike

我做了一个宏,它输入了一个 powerpoint,遍历幻灯片,如果幻灯片有图表,它会打开它的 excel 并更改一些值。

但是我在对特定幻灯片编号执行特定功能时遇到问题,宏无法识别幻灯片编号并对每张幻灯片执行相同的操作。

这是不完整的代码(我只是没有添加所有代码,因为它可能太长了):

'Iterate through slides
For Each sld In PowerPointApp.ActivePresentation.Slides

With sld.Shapes(1)

If .HasChart Then
Set oPPChart = .Chart
Set oPPChartData = oPPChart.ChartData

oPPChartData.Activate

'Set Excel objects
Set oXlWb = oPPChartData.Workbook
Set oXlApp = oXlWb.Parent

Call CalcCopyPaste(oXlWb)
Call DeleteColumnLastUsed(oXlWb)

'Remover headers
Select Case OPCountry

Case "US"

'Remover headers só!
If sld = 8 Then

Range("U5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("C3").Select
ActiveSheet.Paste


Else
Range("S3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
Range("S1").Select
ActiveSheet.Paste

End If

End Select

oXlWb.Windows(1).Visible = False
oXlApp.Visible = False

End If

End With

Next sld

因此,对于幻灯片 8,它应该执行 IF 中所述的特定操作,但它在每张幻灯片上都执行了所有操作!
你能帮忙吗?谢谢!

最佳答案

正如 BruceWayne 所提议的,我通过以下方式解决了:

Select Case UCase(OPCountry)


Case "US"
'Conditions for slide 3, 4 and 5

If sld.SlideNumber = 3 Or sld.SlideNumber = 4 Or sld.SlideNumber = 5 Or sld.SlideNumber = 6 Then

With sld.Shapes(1)

If .HasChart Then

Set oPPChart = .Chart
Set oPPChartData = oPPChart.ChartData

oPPChartData.Activate

'Set Excel objects
Set oXlWb = oPPChartData.Workbook
Set oXlApp = oXlWb.Parent

我刚刚更改了 SlideNumber任何我想要的幻灯片。我认为问题出在 excel 的编译器中,因为它(可能)打开了许多进程。

关于excel - 检查当前幻灯片的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31143619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com