Loop through, open, perform SendKeys on pdf files in one folder

一曲冷凌霜 提交于 2020-05-17 07:26:23

问题


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

Unfortunately this just continually opens and closes the first file in the folder which is referenced in my create object line

来源:https://stackoverflow.com/questions/60046336/loop-through-open-perform-sendkeys-on-pdf-files-in-one-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!