Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

open file Error

Posted on 1998-06-11
1
Medium Priority
?
170 Views
Last Modified: 2010-05-03
When i do the following , VB gave me a path not found message (highlighting line 2) Why ?
open "c:\windows\temp\file1.text" for Input as #1
open "c:\windows\temp\file2.text" for Input as #2
Data = "Myname"
Put #1 Data
0
Comment
Question by:kwl
1 Comment
 
LVL 4

Accepted Solution

by:
yowkee earned 200 total points
ID: 1463169
kwl,

  What it really means is the file "c:\windows\temp\file2.text" is not existed! Open statement will create file for non-existed file path *only* for Append, Binary, Output, or Random modes.

  Besides, it is better to use the FreeFile function to obtain the next available file number.

eg.  Dim iFile as Integer
     iFile = FreeFile
     Open "C:\temp\test.txt" for output As #iFile

Regards.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question