Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing an open file from VBScript

Status
Not open for further replies.

Zooby12

Programmer
Aug 10, 2011
8
US
I would like to close an open file from VBScript. So far with what I have, it keeps on telling me I need an object. I'm not sure how/what object to create for this instance. I'm very new to VBScript and still trying to get the hang of it with the object concept. Here's the little I have (although I don't expect more than one line more):

Dim myfile
set myfile = "..\..\load\pems\ofp\nvm_translator\nvm_tutorial_pems.pptx"
myfile.Close
 
something like this
Code:
set oFSO = CreateObject("Scripting.FileSystemObject")

const ForReading = 1, ForWriting = 2, ForAppending = 8 
'open the input file for reading
set oInFile = oFSO.OpenTextFile("xml_input.xml", ForReading)
'open the output file for writing
set oOutFile = oFSO.OpenTextFile("xml_output.xml", ForWriting, True)
...
'process files
....

'close the input file
oInFile.close
'close the output file
oOutFile.close

look and try some working examples of file processing here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top