ie.execwb code/auto print issue

G

Guest

We are trying to run a vb script to print two html files that is
automatically created daily. Here is the general code:

Dim path, fext
'Set the path to the dir to be searched
Path = "C:\HTMLFiles\"
'Set the file extension to search for
fext = "htm"
'************************************************

Dim fso, fol, s, r, r2, t, filfull, fols, fols1, fols2, fol1, fol2, fol3
Set fso = CreateObject("Scripting.FileSystemObject")

set t = fso.CreateTextFile(Path & "result.txt", true)
set fol = fso.GetFolder(path)
on error resume next
folprocess fol
t.Close
'Dim oWSHShell
'Set oWSHShell = WScript.CreateObject("WScript.Shell")
'oWSHShell.Run "Notepad /p " & path & "result.txt", 7, true

set t = nothing
fso.DeleteFile(path & "result.txt")

'Process folder subroutine
sub folprocess(obfol)
dim fil, fil1, dlm, pfil, fils, maxfil1, maxdlm, maxpfil
maxfil1 = ""
set fils = obfol.files
for each fil in fils '-- do files in folder
pfil = fso.GetAbsolutePathName(fil)
't.write pfil & vbcrlf
If lCase(fso.GetExtensionName(pfil)) = fext then
set fil1 = fso.GetFile(pfil)

dlm = fil1.datelastmodified
if dlm > maxdlm then
maxfil1 = fil1
maxdlm = dlm
maxpfil = pfil
end if
set fil1 = nothing
end if
next
If maxfil1 = "" then
t.write "No 'htm' files in dir"
else
t.write vbcrlf & vbcrlf
t.write "Most Recent '" & fext & "' file in " & path & vbcrlf & vbcrlf
t.write maxfil1 & " modified " & maxdlm & VbCrLf & VbCrLf

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate maxpfil
While IE.Busy
WScript.Sleep 100
Wend
IE.ExecWB 6, 2
WScript.Sleep 1000
IE.Quit

end if
set fils = nothing
end sub


From this we created two individual files "Eff Reports.vbs" and "Water
Reports.vbs". The only difference between the two files is the path
designated in
Path = "C:\HTMLFiles\"
One of them points to C:\POC\Reports\Effl Syst\ and the other is
C:\POC\Reports\Water Syst\

For some reason the water report.vbs file opens the .htm file, sends to
printer, and then closes ie. The Effl Report.vbs file opens the .htm file,
and closes the file without sending it to the printer. Any suggestions or
explanations on the ie.execwb would be appreciated.
 
G

Guest

Thanks for the suggestion. I will try it next time I am out there and let
you know the results.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top