Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Files


Message #1 by "LaFerriere, Patrick M." <PLaFerriere@T...> on Tue, 15 May 2001 09:09:33 -0400
Instead of saying "Open tFileObj For Output As #hFile" try using "Open
tFileObj.Name For Output As #hFile" (use tFileObj.Name) because Open expects
a string as file name and not a file object. You are seeing the file path
when you hover above it because the Name property of tFileObj is the default
property and it is showing this value.

Hope this helps.

-----Original Message-----
From: LaFerriere, Patrick M. [mailto:PLaFerriere@T...]
Sent: Tuesday, May 15, 2001 9:10 AM
To: professional vb
Subject: [pro_vb] Files


I have a need to create XML documents on the fly. I am using vb6 sp4. I'm
not having much luck using the FileSystemObject. It seems that I can create
the file with the .xml extension but I can't access the file after it's
created. I get the standard "Permission Denied, Error 70". It happens on the
line that reads "Open tFileObj For Output As #hFile" . When I hover over the
file it shows me the correct path and filename of the file that was just
created but I still get the error. Why????

I need to be able to create files and save them so that I can HTTP all the
files in the directory after all the order creation is done. (This is being
used to create salesorders for one of our contractors)

Private Sub OutPutXml(ByVal XML As String)
Dim Document As Object
Dim hFile As Integer
Dim tFileName As String
Dim tFile
Dim FSO As Object
Dim tFileObj
    
    'On Error GoTo ErrHandler
    Set FSO = CreateObject("Scripting.FileSystemObject")
    tFileName = "TOI" & Format(Time, "hhmmss") & ".XML"
    Set tFile = FSO.CreateTextFile(App.Path & "\" & tFileName, True)
    Set tFileObj = FSO.GetFile(App.Path & "\" & tFileName)
    
    hFile = FreeFile
    'Open App.Path & "\temp.xml" For Output As #hFile
    'Open App.Path & "\" & tFileName For Output As #hFile
    Open tFileObj For Output As #hFile
    Print #hFile, XML
    Close #hFile
    
    XMLBrowser.Navigate App.Path & "\" & tFileName
    
    Exit Sub
ErrHandler:
    On Error Resume Next
    Close #hFile
End Sub



  Return to Index