Print Page | Close Window

Variable Filename in OpenTextFile

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7634
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Variable Filename in OpenTextFile
Posted By: fark
Subject: Variable Filename in OpenTextFile
Date Posted: 26 November 2003 at 4:56pm

 I'm trying to open a text file using this statement

Set objTextFile = objFSO.OpenTextFile (File, fsoForReading, False)

but I get this error.

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

/ups/csvfile2.asp, line 71

When I put a static "C:\Inetpub\wwwroot\ups\TempData.txt" instead of a variable it works.  Am I allowed to use a variable for the file name?  I didn't want to spend a huge amount of time error checking what's in the File variable if I can't even do it in the first place.  Thanks.




Replies:
Posted By: FrankHenkel
Date Posted: 26 November 2003 at 5:38pm

Is FSO enabled on your server? 

I had this error once and it was because my host turned off FSO on my server because people were getting into other's sites.  (shared hosting )  They moved me to a server with FSO enabled and it worked fine.

However, I must throw in my disclaimer:  I'm usually wrong!



Posted By: MorningZ
Date Posted: 26 November 2003 at 6:17pm

yes, you can use variables to specifiy location.....

something else is wrong with your code



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Gullanian
Date Posted: 26 November 2003 at 6:29pm
Make sure File isnt a reserved word, try renamin the file variable to strFilePath


Posted By: MorningZ
Date Posted: 26 November 2003 at 6:32pm

excellent point.....

that's some damn good advice right there



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Gullanian
Date Posted: 26 November 2003 at 6:54pm


Posted By: pmormr
Date Posted: 26 November 2003 at 7:49pm

the variable name 'file' is reserved. do what gullanian suggested



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net