I have the following code working in VBS. I cannot figure out how to use it in VBA. Any ideas would be great. I am trying to figure out which PDFs in a folder are in Portfolio format vrs standard format
here is the VBS that works:
The Code says VBA but it actually is VBS
here is the VBS that works:
The Code says VBA but it actually is VBS
VBA Code:
Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory = "C:\Temp"
Function CmdOut(p):Dim w,e,r,o:Set w=objShell :Set e=w.Exec("Cmd.exe"):e.StdIn.WriteLine p&" 2>&1":e.StdIn.Close:While(InStr(e.StdOut.ReadLine,">"&p)=0)::Wend:Do:o=e.StdOut.ReadLine:If(e.StdOut.AtEndOfStream)Then:Exit Do:Else:r=r&o&vbLf:End If:Loop:CmdOut=r:End Function
str = "for /f " & """" & "delims=" & """" & " %f in ('dir /b *.pdf') do @(echo/ && find " & """" & "/Collection" & """" & " " & """" & "%f" & """" & " >nul && echo PORTFOLIO= " & """" & "%f" & """" & " || echo NOT Portfolio or Error " & """" & "%f" & """" & ")"
Dim PortfolioList
PortfolioList = CmdOut(str)
WScript.Echo PortfolioList