Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Print Out Files (dir1 / File1

I am trying to list the files in all the folders, but I can figure out how to code and list a sub folder or Sub Sub folder......
If anyone can offer a direction, thanks

Private Sub List_Files(strFiles As String)
Dim intF As Integer: Dim intA As Integer
File1.Path = strFiles ' BackUp files
Text1.Text = Text1.Text + Str(File1.ListCount) ' File Count
For intA = 0 To File1.ListCount - 1
' Name of File
Text1.Text = Text1.Text + strFiles + "--" + File1.List(intA) + vbCrLf
Next intA
' Are there any sub folders?........
End Sub
Private Sub Start( )
Dim intF As Integer
' Read ...the user already selected start folder from GUI

For intF = 0 To Dir1.ListCount - 1 ' Number of Sub Folders
call List_Files(dir1.Path)
Next intF

End Sub

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
File1, Dir1,Drive1
This is going to be hard to explain but i will do my best.
Ok, i have 5 textboxes and beside those 5 text boxes i have 5 command buttons . When a button is pressed another form pops up with File1 Dir1 and Drive1 boxes in place. When a user selects a file, the file name and path go to the text box that the button was beside. But my problem is that...i don't want to have 5 forms that look and act exactly alike. So i was wondering how should i go about using one form and be able to select files for each of those text boxes.
Maybe the screen shot will explain it better.

Thank you,
ps. I think i would have to store the selected file as a var, but i just have too much code in my head to figure out how.

Dir1 And File1 Simple ?(RESOLVED)
On my form I have a Drive1,Dir1,File1 and txtFile boxes. I find in order to add anything to my txtFile textbox, I have to click on an item twice in the File1 box and I am not sure why.

VB Code:
'//////////// SELECT FOLDER FROM DRIVE //////////////////////Private Sub Drive1_Change()    On Error Resume Next: Dir1.Path = Drive1.DriveEnd Sub Private Sub Dir1_Change()    On Error Resume Next: File1.Path = Dir1.Path    txtFile.Text = ""End Sub        '/////////// PUT FILE INTO TEXT BOXPrivate Sub File1_Click()    File1.Pattern = "*.pdf;*.doc;*.ppt;*.txt;*.jpg;*.gif;*.bmp;*.xls"    Dim txtPath$    txtPath$ = Dir1.Path    If Mid(txtPath$, Len(txtPath$), 1) = "" Then        txtFile.Text = Dir1.Path & File1.FileName    Else        txtFile.Text = File1.FileName    End IfEnd Sub

File1,dir1,etc Pain In Rear(books Are Wrong)
Ive the following code in my project:

Private Sub Dir1_Change()
File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Path

End Sub

Private Sub File1_Click()
Dim SelectedFile As String

SelectedFile = File1.Path & "" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)

End Sub

the only problem is really compiling or changing from primary drive: Reason being is the ".path" part of the commands.
ive seen work arround error more or less resume next then a message box. I want some actual functioning code though or at least find out what I need to start researching to figure this dilema out. Thnaks all in advance. Also
Photovoltai replied with
Lose the "", you don't need it. The error probably comes up when you switch to the root directory of a drive, when dir1.Path will be "C:\" (not valid). Also, you can search through all files in a directory using the Dir$ function.
but this has nothing to do with problem ,thats why im being more specific this time. ty Photovoltai for oyur effortrs though...theyre honestly well appreciated.

Open File1.Path & File1.FileName For Input As #1
I'm tired and frustrated.

Here's the situation:

My project is located in c:projects
A file that I want to open is in c:projects eams

I want the user to be able to run the program from whatever directory, wherever they install it. That's not important. What is important is that the project always tries to open this file from the eams subdirectory whereever the project is.

So if the project is in c:projects , then the project looks to open a file in c:projects eams... If the project is in c:cucumber then the project looks to open a file in c:cucumber eams etc.

The File that the project is trying to open is the selected file in a filelistbox.

The problem:

The filelistbox is seeing the files, and letting me highlight the one I want, but when I click the button to open it for input, I get a "File Not Found". Here's my relevant code:

VB Code:
Private Sub Form_Load() File1.Path = App.Path & " eams"File2.Path = App.Path & " eams"End Sub Public Sub Command4_Click()File1.Path = App.Path & " eams"If File1.FileName = "" Thenyourmsg = MsgBox("Please select a team to load", 0, "Visitor Error")ElseOpen File1.Path & File1.FileName For Input As #1Input #1, vnme, vabb, vovClose #1End Sub

Any takers? I'm sure it's simple. I just need some fresh air.

Determining If DIR1.PATH Contains More Folders Or Only Files ?
When you use a basic DIR1.path menu, is there a control that can let you know if more folders are contained WITHIN that directory ?


I currently refresh my folder list back to c:mp3 after every click. BUT, if there is a folder that contains musiccd1 and musiccd2 , etc, I DONT want to refresh back to c:mp3, I want DIR1 to act as normal. BUT only when there are more directory trees inside.

Ok, like,

If "folder_contains_no_folders" then
file1.path = dir1.path
dir1.path = "C:Mp3"
goto end
end if
elseif "folder_contains_More_folders" then
file1.path = dir1.path
goto end
end if

Is that acheivable ?

Creating Multiple Files, File1, File2, File3 Etc
Hi all

I've wrote a program that allows me to capture a still image off a webcam, however, everytime i capture the image it overwrites the previous one, how can I automatically rename them file1, file2, file3 etc. I'm using the ezVidCap.ocx to create the webcam.

Private Sub CaptureFrame_Click()

ezVidCap1.SaveDIB "C:Image.DIB"

End Sub

Thanks all for help

Dir1 To Listbox1
how can i gewt the contents of a DIRlist control into a listbox?

Need Help With Dir1.Count
I need to have my Dir ListCoun show up in my text file, but I only need it to show up once. So the text file would read:

&DLc=6&Folder0=Billphotos&Folder1=Jimphotos... and so on.

This is what I tried but it puts in the count with every Folder.

Option Explicit

Dim StringToWrite As String
Dim i As Integer

Private Sub Command1_Click()

'Dir1.Path = "C:HoweFamilyHowePictures"

StringToWrite = ""
For i = 0 To Dir1.ListCount - 1

StringToWrite = StringToWrite & "&DLc" & "=" & Dir1.ListCount & "Folder" & i & "=" & Right$(Dir1.List(i), Len(Dir1.List(i)) - InStrRev(Dir1.List(i), ""))
If i <> Dir1.ListCount - 1 Then StringToWrite = StringToWrite
Next i

Open "C:HoweFamilyHowePictures emp.txt" For Binary As #1
Put #1, 1, StringToWrite
Close #1
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File1.Pattern = "*.jpg"
End Sub
Thats the first thing I need to do. The second seems a liitle more complicated for me any ways. What the code above does is gets the folder names of the directory I am in and out puts them into a text file. What I need to do next is get the contents of those folders into a text file.

So if I have Billphotos as the folder name and in this folder there are several pictures of Bill in .jpg format. I want to right a text file called Billphotos.txt that contains the following:

&DLc=23&pic0=billsmiles.jpg&pic1=billfalls.jpg...and so on.

If my directory has 25 folders each named differently I would ultimately need a single text file listing the folder names(done) and 25 text files listing the contents as specified above. I sure would appreciate any help in this matter.

Has anyone experience this yet?

Window ME
Dir1.Path = a "" automatically concatenate to the end of the path.

Window Nt
Dir1.Path = NO "" is concatenate to the end of the path.

Add Dir1 Dirs In Combo1?
Hi, how can i use combo1.additem dir1.list

or something like that?

i mean.. adding dirs in C:visualbasic to a combo?

Folders And SubFolders In A Dir1
I'm sure somewhere on here is code to have a program run through a set directory and return ALL the subfolders of that directory, but I can't seem to find anything.

I have a Dir1 box that I want to have set to a folder (lets say c:program files just for kicks)

I want it to return a list of all the folders, subfolders and subfolders below that (as far down as it goes).

I've been trying to do this in a loop but can only get it to go as deep as however many folders I tell it to go deep..

how would I go about doing this?

How Link Dir1 To Dir2
How link Dir1 to Dir2 thereby Dir2 show the subdirectories of the Dir1 subdirectory selected

FileCopy To Dir1.Path
Why doesn't this work............Using VB 6.0:

Private Sub SaveBtn_Click()
Dim sFiles1 As String
sFiles1 = Dir1.Path
Dim rs As Integer
rs = MsgBox("Are you sure you want to save to " & Dir1.Path & "?", vbOKCancel)
Debug.Print rs, vbOK, vbCancel
If rs = vbOK Then
Dim fso As FileSystemObject, fil As File
Set fso = New FileSystemObject
Set fil = fso.GetFile(App.Path & "File.dxf")
fil.Copy sFiles1, True
ElseIf rs = vbCancel Then
Exit Sub
End If

I get an error at the fil.copy statement, and when I go through and recheck the code the sFiles1 reads correctly. I don't know whats wrong, can someone please help me
End Sub

Merge Word Files And Print To PDF Print
Looking for code would allow me to merge multible word files into a single file and print to a single pdf file.

Winsock1.senddata Dir1.list
Hello again people,

I got an client/Server app, but with a lil' problem. I want to send the Dir1.list to the Client (list1) thru winsock, how to do that?

Double Click Dir1 With Code?
Is there any way I could double click the folder list box with vb code?

I want the folder list box to change folders automatically
something like:

Dir1 is currently set to c: estingDirlistbox

strPathA = Dir1.Path
Dir1.listindex - 1
strPathB = Dir1.Path

With this code dir1 only highlights the folder, its not actually selecting it, like a double click, and the 2 strings come out the same c: estingDirlistbox

How do I get the Dirlist to double click automatically back one folder to c: esting?
The line strPathB needs to return the path below strPathA.

Any help is appreciated!

Getting The Directory Info From Dir1 *RESOLVED* :)
I was wondering how i could get the directory information of a selected directory from dir1.

i know i can use dir1.path but that only sends me the directory that i am in.
I have a folder with some sub folders in it and i would like to retrive the folder name when i "make the folder blue" not when i enter it.
just like the file1.filname statement.

Hope you understand what i mean.

Have a nice day


Edited by - Wizkidno on 5/13/2004 4:42:13 AM

Printing Multiple MSWord Files. Files Do Not Print In The Same Order As Instructed By Code
I am printing multiple Word files from VB using the code indicated below. The order in which they come out of the printer is not the same as that followed by the code.

What can I do to get them to come out of the printer in the same exact order as executed by the code.

Code Used:

For nI = 0 to n

sFile = "File" & Trim(Str(nI)) & ".doc"

Documents.Open FileName:=sFile, ConfirmConversions:=False, ReadOnly:=
True, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="" , Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="",

ActiveDocument.PrintOut Range
            :=wdPrintAllDocument, Item:=wdPrintDocumentContent, Copies:=1, Pages:="",
             PageType:=wdPrintAllPages, Collate:=True, Background:=True, PrintToFile
            :=False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0,


I want to test the content of the filelistbox that is populated with a file. What variable contains the value/s of the filelistbox?

File1 Box
I'm wondering if in a file list box I can change the color the file name turns when it is selected.
Also is there a way to make it stay selected even if I close and re-open the program. (until I choose to unselect it)



Print/create Postscript Files From Pdf Files
The problem: Many files in any formats (doc, xls, rtf, PDF) must converted by a program (VB) to postscript format without an file name question dialog. For MS-Office-files it's no problem, it works very good, but for pdf:
I've found no way to do it. The Acrobat function "save as" has no API (it's right ? i have read the SDK) and there is no way to give the name of the output file to the Adobe postscript printer driver (using the AcroExch object).
Can you help me ?

Execute.exe &lt;File1.txt&gt;
I compile my vb program to a execute.exe. I need to know how to code the vb so that it will accept an external file during execution from DOS.
Any idea how to make the execute.exe to accept the input <file1.txt>?



File1.list HELP
My intention is to make the timer act as a loop, and perform a set attributes on every file in a directory. Unfortunatly I don't know how to get the timer to stop when it has set the attributes for the last file. HOW, do I get this to work...

Private Sub TimerMyFOLDER_Timer()
XList = XList + 1
XYpath = "C:MyFOLDER" + XYFileName
File1.Path = XYpath
XYFileName = File1.List(XList)
retval = SetFileAttributes(XYpath, FILE_ATTRIBUTE_NORMAL) ' set the file's attributes
TextPathName.Text = XYFileName
'IF it's the last file, timer1.enabled = false
End Sub

I use VB 5.0

File1 Problem
hello everyone.

i have got a problem with File1

I wrote
VB Code:

in the Private Sub Dir1_Change().When i am on a file which contains .exe files
like my documents it still has the exe files of the first Directory
and the new what is the problem ?

Execute.exe &lt;file1.txt&gt;
I compile my vb program to a execute.exe. I need to know how to code the vb so that it will accept an external file during execution from DOS.
Any idea how to make the execute.exe to accept the input <file1.txt>?



File1 Problem
hi guys,

i have a problem, i have made drive, dir, and file boxes all link together - thats fine, but i have also included a listbox wich receives the file names, and a rightclickable menu. when i right click the menu and select one of the options with the mouse it runs the code perfect, but if i use the keyboard eg ctrl + a, the file1 box doesent listen to the code.

what have or havent i done?

is there another way of doing this, eg using code within the file1 box to use shortcut keys?


File1 Issues...
o.k. so i have a control on my form1 called file1.
and it shows files in a certian dir
now i also have a text1 and a command1
what i want to happen is when i click command1 the file list in file1 will be printed out into text1

i'm looking for the small snippet of code to do this for me..
other info is i use vb6.0
as well i am not new to this.. just never needed the uses of file control before. and every time i post a question there is questions on what i mean, beacuse i made too many assumptions. hopefully the question i posed should be understood by all.

File1 &amp; Image1
I want that if I click on a file on file1 then the image should show in image1 please tell me the code + also tell me the code to close an application from a button.

Loop A File1.listbox?
How could I Loop a File1 listbox
and copy to another directory
I have a Dir1.listbox and File1.listbox and need to
do a loop. I noted that It uses Index, or had error
What loop would work - with Index 0 to what ever
the file1.listcount or something like that, so I can copy
all in the file1.filenames without incountering an error?

Change The Display Of File1
Is it possible to change the display of the files from a list to icon view. If so how do i do it.

Thanks in advance

ComboBox With File1 SetFocus Problem
Basically trying to SetFocus to a File1Box after User selects one of the ComboBox's dropdown list choices

if User Clicks on ComboBox's "Picture Files" the File1Box shows Bitmaps and Jpegs

if User Clicks on ComboBox's "Movie Files" the File1Box shows Mpegs,Avi,MP3

Problem is => getting RunTime Error "5"
can't SetFocus to File1Box from ComboBox Click Event

can't SetFocus to File1Box from ComboBox Click Event

here's simple code to simulate problem

Option Explicit

Private Sub Combo1_Click()


End Sub

Private Sub Form_Load()

' Style=2 Simple Dropdown List
Combo1.AddItem "Picture Files"
Combo1.AddItem "Movie Files"
Combo1.ListIndex = 0

End Sub

so far i haven't found a solution to SetFocus problem, especially if there are more than 2 Forms in Application or there are Midi Forms and Child Forms in App

any Help appreciated !!

Compile Errors With File1.path
I cant seem to use file1.path, dir1.path...etc can someone tell me why my program wont compile or give me an alternative measure for this. Ive included my program to view. Thnak you all in advance..Everyone here has been very helpful

How To Set File1 To A Specific File Type
I want to use File1 control but only show files that have an extension of .lnk.

How do I do that?

Instr (1,a$, FrmImage.File1.List(b))
I have tried several ways to compare. I have used Instr many times before.
frmImage.File1.List(b) will not equate. This is not a string
Not a string, what is it?

For b = 0 To frmImage.File1.ListCount - 1
intFnd = InStr(1, Str("030182"), frmImage.File1.List(b))
If intFnd > 1 Then Debug.Print b: b = frmImage.File1.ListCount - 1: z = 1

Sample of File1.list....030182 Ornament Hanger.jpg

How To Change Charset In File1.list Vb6
Having problems displaying macitosh generated icon file.

I think it is a character set problem.

How do you change charcter set for a file list box.

Not the font type.


Merge Current Record From File1 To File2
Hello, everyone. Can someone help me? I open file #1 and want the current record, which is showing on the screen, to merge to file #2. This is what I did. I opened file #2 and saved the current record to it. I got only a blank record added to file #2. Can anyone give me any suggestions or a sample code? I looked thru the forums and didn't find any thing relevant to what I need. Thank you.

Help On Auto Renaming File1, File2, File3 Etc
Hi, its me again
last question for that day

I got this test program i wrote that generates random numbers at a 5 second interval and i got it to capture the number and save it to a file eg at c:file1.txt

the problem I got is that it overwrites the file testfile1.txt every 5 seconds. I want it to create and save each one into a different txt file name eg using a for loop that creates file1, file2, file3 etc
How you understand, thanks in advance

File1.path Error 380 Invalid Property Value
Can you help me ?

I'm basically reading into a filelistbox (file1) a folder of .pdf's from a network drive.

Private Sub Form_Load()

Dim fs As New FileSystemObject

'check for scans folder
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FolderExists(location & "scansTRTO")) Then
fs.CreateFolder location & "scansTRTO"
End If

Dir1.Path = location & "scansTRTO"
File1.Path = Dir1.Path
File1.Pattern = "*.pdf"

The above lines in red give me an Error 380 Invalid property value.

I just can't fathom it out.
"location" is the mapped network drive path ie: "D:Training"

The error only shows when I run the program on the clients PC not on mine.

Any ideas Guys?

*solved*how To Replace File.exe With File1.exe While Running..
HI there...

If i wanna update my .exe while running (is this possible?)how can i do it ?

Code:Kill App.Path & "Autolek.exe"
Name App.Path & "Autolek1.exe" As App.Path & "Autolek.exe"

I tried form unload, but its still running......? any ideas on how to do it?

Or do you think making a .exe with the above code and on form_Unload fire up the kill.exe?

Edited by - Hopeless on 9/3/2004 3:44:12 PM

Double Click Eml File In File1 Control To Open
I have an eml file that I can open in windows explorer simply by double clicking on it. Outlook Express
only opens that particular email window for that file and not for the whole program. Now I would like to
be able to do the same thing in a vb program by clicking on a file within a file listbox control. Anyone
out there no how to call the program. Right now when I use a shell command to call the eml file, I get
and error msg saying the file is not found.

Print .ps Files
How can i print a .ps file, send it strait to the printer?

Print Tif Files
Hi gurus

I have some tif files that I would like to print, I dont need to view them or open them at all, just load and print.Would some one point me to the right direction please

Thanks a bunch

Print Pdf Files
Hi gurus.

I would like to know where do I start with the following problem:

I have a few pdf files that I would like to print, can someone point me to the right direction or any dll I might use in order to do this painless.-

Thanks again

Print PDF Files
Please help, could someone please tell me is there a way to use vb code to print pdf files.....

Print Pdf Files
Hi, I would like to know if there is a way to print pdf files using vb code?

Print Files
I would like to write a program that will open, print, and allow editing or at least previewing of print files.
Print files are unsupported by windows, but the option always comes up in standard print dialog boxes.
The format apparently uses the printer's protocol - because if you copy the file to the correct printer's port, then it prints. If you sen it to an incorrect printer then it may print a different thing altogether.
Presumably, I would need to send it through the print driver assigned to the printer.
Can anyone say how I would do this, and what the output would come as?

How To Print Jpg Files From Vb??

can any one help me to print jpg files from vb??thanx in adv.

How To Print Pdf Files In
Hi ya'll, I'm looking for a printing snippent for I need to push multiple pdf files into the printer via



Copyright 2005-08, All rights reserved