INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Receiving Permission denied error when attempting to append txt file

Receiving Permission denied error when attempting to append txt file

Receiving Permission denied error when attempting to append txt file

(OP)

Receiving the following error:

Permission denied

Line (3617): "Set qfile = fso.OpenTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest2.x12", ForAppending,True)".

Code:

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso=createobject("Scripting.FileSystemObject")
Set qfile1 = fso.OpenTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest2.x12", ForAppending,True)
qfile1.WriteLine("last line of text.")


What could be causing this and how can I get access?

I was able to create the file using the following code that is in the same script


Set fso=createobject("Scripting.FileSystemObject")
'Create a non existing file "qtptest.txt " with overwrite option as True
'Set qfile1=fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP Test 834\Text files\qtptest1.txt",true,False) ' textname could become a variable so that many could be generated
'Set qfile1=fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP Test 834\Text files\ X",true,False)
'Set qfile1=fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP Test 834\Text files\ &(DataTable.Value("TxtFileName",dtGlobalSheet)",true,False)
Set qfile1=fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\" & TextFileName,true,False) 'TextFileName used as a variable so that multiple 834 files can be generated from DataTable
qfile1.Write((DataTable.Value("Interchange_Control_Header",dtGlobalSheet)))
qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))

qfile1.Write((DataTable.Value("ISA01_I01_Author_Info_Qualifier",dtGlobalSheet)))







RE: Receiving Permission denied error when attempting to append txt file

Can't be sure since I can't see all your code, but I'm going to guess that qfile1 is still open from the "Set qfile1=fso.CreateTextFile(...)" line, causing permission denied when you try "Set qfile1 = fso.OpenTextFile(...)"

If this is the case, there is no need to use OpenTextFile, since the file is already open. Alternately, you could add "qfile1.Close" before the OpenTextFile line.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close