Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Still have Permission error when saving txt file! Help.


Message #1 by "Nigel Spicer" <spicerman@t...> on Fri, 7 Dec 2001 12:45:35
Hi...

Looks like you have a logic err in your code...

You need to create the filename string before you open the file.
It looks like you try to open a file named nothing

/Daniel

Private FSO As Scripting.FileSystemObject
Private Sub Form_Load()
    Set objFile = New Scripting.FileSystemObject
End Sub

Private Sub Command1_Click()
    Dim ts As TextStream
    Dim sFileName As String

    sFileName = FSO.GetSpecialFolder(TemporaryFolder)
    sFileName = sFileName & "\spd.txt"

    Set ts = FSO.OpenTextFile(sFileName, ForWriting, True)

    ts.WriteLine "HelloWorld!!"
    ts.Close
End Sub


At 12:45 2001-12-07 +0000, you wrote:
>PLEASE EMAIL ME DIRECTLY AT spicerman@t... its faster.
>
>permission error at :
>
>         Set Ts = objfile.OpenTextFile(strFileName, ForWriting) IN :
>
>Private Sub Command1_Click()
>
>         Set Ts = objfile.OpenTextFile(strFileName, ForWriting)
>
>     strFileName = objfile.GetSpecialFolder(TemporaryFolder)
>     strFileName = strFileName & "\Spd.txt"
>
>
>
>         Ts.Write strText
>                 Ts.Close
>
>     MsgBox "Text Saved", vbInformation
>
>
>End Sub
>
>GENERAL DEC.
>Private objfile As New FileSystemObject
>
>     Dim strDatabaseName As String
>     Dim strFileName As String
>     Dim Ts As TextStream
>     Dim strText As String
>
>Reference. Microsfot Scripting Runtime & Activex Data Objects 2.5 library
>
>Nigel...


  Return to Index