PDA

Click to See Complete Forum and Search --> : Create new file


joey o.
Dec 27th, 1999, 08:04 AM
Help,Thank You, and Happy Holidays!
What's wrong with this code? I get a "path not found" error used within form and "invalid outside procedure" error when used in module. I can't remember how to do this. I'm using this part of a code found here that was edited by "Kieko":

Type Record
FirstDate As Date
MaxDate As Date
Count As Integer
End Type

Dim rec As Record
Dim strFile As String
Dim blnSuccess As Boolean

blnSuccess = False
strFile = "c:\windows\desktop\rnd\a.txt"

If (Dir(strFile) = "") Then
'not found then create a new one
Open strFile For Random As #1 Len = Len(rec)
rec.Count = 0
rec.FirstDate = Date
rec.MaxDate = Date
Put #1, , rec
blnSuccess = True
Close #1


Can anyone help me?
Have a great new year even if you can't,thank you!
JoeyO

Clunietp
Dec 27th, 1999, 09:55 AM
You get "Path Not Found" because you do not have a folder called 'RND' on your desktop. Add some code to check for the existence of this folder, and create it if it does not.

HTH

Tom

joey o.
Dec 28th, 1999, 06:15 AM
Clunietp:
Thats the point. I need to know how to create it. Is there a command like:
Create.NewFile = "C:\MyNewFile"? I feel like an idiot because I know I did it before but I've got no refrence books with me. Can anyone help me out?

Clunietp
Dec 28th, 1999, 12:13 PM
here ya go Joey:


If Dir("C:\TEST", vbDirectory) = "" Then
MkDir ("C:\TEST")
Else
MsgBox "Test already exists!"
End If

'save file here, the directory exists



Tom

joey o.
Dec 28th, 1999, 09:34 PM
Thanks Again You guys are awsome!