首页 > 解决方案 > 在一个文件夹中的 pdf 文件上循环、打开、执行 SendKeys

问题描述

Sub Password()
    'Loop through all files in a folder
Dim fileName As Variant
fileName = Dir("C:\State_K-1_Info\Password\*.pdf")

Do While fileName <> ""

    CreateObject("Shell.Application").Open ("C:\State_K-1_Info\Password\001.pdf")
    Application.Wait Now + 0.00005
    'Insert the actions to be performed on each file
    'This example will print the file name to the immediate window
    Application.SendKeys "{Tab}", True
    Application.SendKeys "^(s)", True
    Application.SendKeys "%{F4}", True

    'Set the fileName to the next file
    fileName = Dir
Loop

End Sub

不幸的是,这只是不断打开和关闭我的创建对象行中引用的文件夹中的第一个文件

标签: vbaloopspdfsendkeys

解决方案


推荐阅读