0

Here is my code:

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

I assume I need some statement that opens the the pdf after the While line, but nothing I have tried works.

Simon Notley
  • 2,070
  • 3
  • 12
  • 18
rbrb19
  • 19
  • 2
  • What application is this code hosted in? – BigBen Jan 28 '20 at 22:57
  • What about this: https://stackoverflow.com/a/39903527/2193968 ( `Shell "explorer.exe " + fileName` ) or if that doesn't work https://stackoverflow.com/a/18922262/2193968 ( `CreateObject("Shell.Application").Open(fileName)` ) – Jerry Jeremiah Jan 29 '20 at 00:49
  • Thank you. This now opens the file. Unfortunately this just continually opens and closes the first file in the folder which is referenced in my create object line – rbrb19 Feb 03 '20 at 19:55
  • How can I get it to move on to the next file? Here is my code: – rbrb19 Feb 03 '20 at 19:56
  • 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 Application.SendKeys "{Tab}", True Application.SendKeys "^(s)", True Application.SendKeys "%{F4}", True 'Set the fileName to the next file fileName = Dir Loop End Sub – rbrb19 Feb 03 '20 at 19:57

0 Answers0