我有一个包含10个PowerPoint演示文稿的文件夹。每个演示文稿都有20-25张幻灯片。
假设我有一个关键字“ CX404”,“ AR50”。该宏应删除10个演示文稿中所有带有该关键字的幻灯片。
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var c1 = ScrollController(); // controller declaration
var c2 = ScrollController();
@override void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
print('start');
return Scaffold(
appBar: AppBar(
title: new Text('data test'),
),
body: new Container( //===================================
padding: EdgeInsets.all(30),
color: Colors.blue[100],
height: 200,
child: NotificationListener<ScrollNotification>(
child: Column(
children: <Widget>[
Text('SOME TEXT HERE'),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: c1, // KONTROLER
child: Container(height: 50, color: Colors.green[100], child: Row( children: <Widget>[
Container(width: 100,child: Text('+MOOOVE -')),
Container(width: 100,child: Text('-MOOOVE -')),
Container(width: 100,child: Text('-MOOOVE -')),
Container(width: 100,child: Text('*MOOOVE *')),
Container(width: 100,child: Text('-MOOOVE -')),
Container(width: 100,child: Text('-MOOOVE -')),
Container(width: 100,child: Text('-MOOOVE +')),
],),)
),
Text('ANOTHER TEXT HERE'),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: c2, // KONTROLER
child: Container(height: 50, color: Colors.red[100], child: Row(children: <Widget>[
Container(width: 100,child: Text('+ FOLLOW-')),
Container(width: 100,child: Text('- FOLLOW-')),
Container(width: 100,child: Text('- FOLLOW-')),
Container(width: 100,child: Text('* FOLLOW*')),
Container(width: 100,child: Text('- FOLLOW-')),
Container(width: 100,child: Text('- FOLLOW-')),
Container(width: 100,child: Text('- FOLLOW+')),
],),)
),
]),
onNotification: (ScrollNotification scrollinfo) { // HEY!! LISTEN!!
c2.jumpTo( c1.offset ); // c1 is controlling c2's offset
print('OFFSET--'+c1.offset.toInt().toString()+"--"+c2.offset.toInt().toString());
},
)
), // ===================
);
}
}
我可以打开文件夹中的所有ppts。我无法使用特定的关键字删除幻灯片。
答案 0 :(得分:1)
我对您的商家信息进行了少许修改,对我有用:
Option Explicit
Public Sub DoFiles()
Dim strFileName As String
Dim strFolderName As String
Dim PP As Presentation
Dim sText As String
strFolderName = "D:\111\"
strFileName = Dir(strFolderName & "\*.pptx*")
sText = "TEST"
Do While Len(strFileName) > 0
Set PP = Presentations.Open(strFolderName & "\" & strFileName)
Dim oSld As Slide
Dim oShp As Shape
Dim L As Long
For L = ActivePresentation.Slides.Count To 1 Step -1
Set oSld = ActivePresentation.Slides(L)
For Each oShp In oSld.Shapes
On Error Resume Next
If oShp.HasTextFrame Then
If UBound(Split(oShp.TextFrame.TextRange, sText)) > 0 Then
PP.Slides(L).Delete
End If
End If
Next oShp
Next L
PP.Save
PP.Close
strFileName = Dir
Loop
End Sub