找回密码
 立即注册
搜索

删除的占位符,怎样用VBA恢复回来呢

3
回复
821
查看
[复制链接]

3

主题

6

帖子

73

幻币

一流武者

Rank: 3Rank: 3

积分
302
QQ
2019-8-15 09:20:55 显示全部楼层 |阅读模式
Sub 删除占位符()
Dim sld As Slide, shp As Shape, found As Boolean
Do
found = False
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type = 14 And Not shp.TextFrame.HasText Then
found = True
shp.Delete
End If
Next
Next
Loop While found = True
End Sub
PPT学习论坛
回复

使用道具 举报

2

主题

8

帖子

9

幻币

一流武者

Rank: 3Rank: 3

积分
235
QQ
2019-8-15 10:50:11 显示全部楼层
难。
ppt好像只记录增加的。
建议:
1、在删除过程中,你可以记录下你删除的图形,设置个参数,在恢复时的调用。
2、ppt窗口有个撤销,也就是Ctrl+Z,如果想用程序实现,可以向ppt窗口发送组合键(不是代码窗口),但是这个过程不能间隔。所以它是个撤销的程序。
我有个程序,虽然暂时没能实现,但可以给你提供参考。修改下,估计能实现。
PPT学习论坛
回复 支持 反对

使用道具 举报

1

主题

6

帖子

20

幻币

一流武者

Rank: 3Rank: 3

积分
209
QQ
2019-8-15 11:43:33 显示全部楼层
应该是撤销程序
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwnd1 As Long, ByVal hwnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function PostMessage Lib "user32" Alias &quotostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal Scan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

    'Private Const WM_KEYDOWN = &H100     '按下键位
    'Private Const WM_KEYUP = &H101       '弹起键位
    'Private Const WM_CHAR = &H102        '清除键位
    'Private Const WM_SYSKEYDOWN = &H104  '按下系统键位
    'Private Const WM_SYSKEYUP = &H105    '弹起系统键位

    Private Const VK_CONTROL = 17
    Private Const vbKeyZ = 90
    Private Const WM_KEYDOWN = &H100
    Private Const WM_KEYUP = &H101
    Private Const WM_CHAR = &H102

    Private Const GW_CHILD = 5
    Private Const GW_HWNDNEXT = 2

    Private Sub 查找窗口句柄getprocessname()
      Dim lngDeskTopHandle As Long
      Dim lngHand As Long
      Dim strName As String * 255
      Dim hwnd As Long
      lngDeskTopHandle = GetDesktopWindow()
      lngHand = GetWindow(lngDeskTopHandle, GW_CHILD)
      Do While lngHand <> 0
         GetWindowText lngHand, strName, Len(strName)
         lngHand = GetWindow(lngHand, GW_HWNDNEXT)
         If Left$(strName, 1) <> vbNullChar Then
            If InStr(strName, &quot;Microsoft Visual Basic - 演示文稿1&quot;) Then
                hwnd = FindWindow(vbNullString, CStr(strName)) '此处s即所需句柄,您可以在此处中断并获取该句柄,或将句柄数据写入数组以获取所有包含&quot;&quot;的窗口句柄
                'MsgBox hwnd
                hwnd1 = FindWindowEx(hwnd, 0, 0, vbNullString)
                'keybd_event vbKeyControl, &H11, 0, 0
                PostMessage hwnd, WM_KEYDOWN, VK_CONTROL, vbKeyZ
                'keybd_event vbKeyControl, &H11, 0, 0
                PostMessage hwnd, WM_KEYUP, VK_CONTROL, vbKeyZ
            End If
         End If
      Loop
    End Sub

复制代码
PPT学习论坛
回复 支持 反对

使用道具 举报

4

主题

13

帖子

44

幻币

一流武者

Rank: 3Rank: 3

积分
237
QQ
2019-8-15 13:50:43 显示全部楼层
试试这个程序,我没怎么看。
演示文稿1.rar (12.28 KB, 下载次数: 159)
PPT学习论坛
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册