Results 1 to 5 of 5

Thread: Create new file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    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

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    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?

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    here ya go Joey:

    Code:
        If Dir("C:\TEST", vbDirectory) = "" Then
            MkDir ("C:\TEST")
        Else
            MsgBox "Test already exists!"
        End If
    
        'save file here, the directory exists
    Tom

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Post

    Thanks Again You guys are awsome!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width