使用VBA,我想循环浏览文件夹中的pdf文档,打开每个pdf,然后在关闭并移动到下一个文件夹之前发送密钥

使用VBA,我想循环浏览文件夹中的pdf文档,打开每个pdf,然后在关闭并移动到下一个文件夹之前发送密钥,vba,loops,pdf,Vba,Loops,Pdf,这是我的密码: Sub Password1() 'Loop through all files in a folder Dim fileName As Variant fileName = Dir("C:\State_K-1_Info\Password\*.pdf") While fileName <> "" 'Insert the actions to be performed on each file Application.SendKeys "{T

这是我的密码:

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

While fileName <> ""


    'Insert the actions to be performed on each file
    Application.SendKeys "{Tab}", True
    Application.SendKeys "^(s)", True
    Application.SendKeys "%{F4}", True

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

End Sub
子密码1()
'循环浏览文件夹中的所有文件
变暗文件名作为变量
fileName=Dir(“C:\State\u K-1\u Info\Password\*.pdf”)
而文件名为“”
'插入要对每个文件执行的操作
Application.SendKeys“{Tab}”,True
Application.SendKeys“^(s)”,True
Application.SendKeys“%$F4}”,True
'将文件名设置为下一个文件
fileName=Dir
温德
端接头

我想我需要一些语句在While行之后打开pdf,但我尝试过的任何东西都不起作用。

这段代码承载在哪个应用程序中?这是怎么回事:(
Shell“explorer.exe”+fileName
)或者如果不起作用(
CreateObject(“Shell.application”)。打开(fileName)
)谢谢。这将打开该文件。不幸的是,这只是不断地打开和关闭文件夹中的第一个文件,该文件在我的“创建对象”行中被引用。我如何才能让它移动到下一个文件?这是我的代码:Sub Password()'循环遍历文件夹Dim fileName中的所有文件,作为Variant fileName=Dir(“C:\State\u K-1\u Info\Password*.pdf”)执行,而fileName“”创建对象(“Shell.Application”)。打开(“C:\State\u K-1\u Info\Password\001.pdf”)应用程序。现在等待+0.00005 Application.SendKeys“{Tab}”,True Application.SendKeys“^(s)”,True Application.SendKeys“%{F4}”,True'将文件名设置为下一个文件fileName=Dir循环结束子文件