Greetings All, I'm quite fresh with ASP and I'm not very good in scripting. Recently I was assigned to develop a function in a web system that developed in ASP, and the function sounds something like this: A printing function that capable to print all files that located in a specific folder. I've tried several codes in VB, but they are not working at all. Thank you very much for your time. Best Regards, Gray d' Newbie
<% Dim fs, fo, x Set fs = Server.CreateObject("Scripting.FileSystemObject") Set fo = fs.GetFolder("c:\inetpub\yourfolder\") For Each x In fo.Files Response.Write(x.Name & "<br />") Next Set fo = Nothing Set fs = Nothing %> Code (markup): That what you're looking for? Oh, and make sure the IUSR account has read access to the specified folder.
Thanks in advance. I will try on the code. I'm just curious but the code you stated doesn't consists any function on printing. How am I supposed to print them? Thank you.
lol, the code he showd write in the browser window, then you go to FILE > PRINT from your browser windows
Yup. I tried on the code. It displays all the file that I have in the browser for instance: a.doc b.doc but if i go to FILE > PRINT, it will print the browser content right, it won't print the file content. Which means that my output will be a piece of paper that has all the files name written on it. Actually I'm looking for codes that can print the contents of the all the files that located in a folder. Thank you very much.
gotta, using this code, in the middle add the reading part, you can find more details about it here TUTORIAL: ASP File manipulations
Thank you very much ludwig. I actually read through the file manipulation before in some of the ASP Tutorial in W3School, but I still didn't find what I'm looking for. From the tutorial I learn how to write into a folder and how to remove them, but I need the function in between which is the PRINTING part so that the sequence goes: WRITE > PRINT > DELETE. Thank you very much for your guidance.
for printing you cannot do with asp, the printer is locally on a computer, asp works server side. you might need to use other things, or get asp to make 1 file out of all and then manually print it
Hi ludwig, I've actually developed a VBA to handle the printing but again it throw me back some error. It is a long story but I try to keep it simple. First let me show you how the code looks like. TargetFolder = "C:\printdocs\" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TargetFolder) Set colItems = objFolder.Items For Each objItem in colItems objItem.InvokeVerbEx("Print") Next This code look sweet in VBA and I tested it, it actually runs seamlessly provided the target folder is in my local desktop. My VBA is actually placed in the server folder and I need to created, print, and remove the files in the server project folder. But if i change my target folder to the folder that placed in the server. It return error as Object variable or With block variable not set pointing on this line: Set colItems = objFolder.Items. I have trying my best to debug this but still no go. Hence I apply the code as VBScript directly in my ASP page and try again. When the code applied in ASP directly as VBScript, it returns another error saying that Microsoft VBScript runtime error '800a01a8': Object required: 'objFolder', again pointing at the line: Set colItems = objFolder.Items. Do you have any idea what I've missed in the code? Thank you very much Best Regards Gray d' Newbie
Hi ludwig, I understand your concern about variable declaration, me myself is concerning on that as well. To be frank, I got this code from another forum, and I'm so amaze that how come this chunk of code can work without having TargetFolder, objShell, objFolder, colItems, and objItems to be dim at the first place. But they are working fine so I didn't really declare them, and I'm quite confuse how the system can recognize them without having me to dim them. P.S. You may try to put this chunk of code into your VB6 and compile it. Trust me, it runs. Thank you very much Best Regards, Gray d' Newbie