Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to use Open statement to open file selected from drivelist and filelist? Pls help!!!

Posted on 2003-02-26
9
Medium Priority
?
160 Views
Last Modified: 2010-05-01
Hi..I try to use the Open statement to open a file that is selected from the drive,dir and file list.However I get an error "File not found" but in actual fact the file does exist.This is what I do:

Private Sub FileERT_Click()
Dim i%, textline$, k1$, a1$, d1$

d1 = DirERT.Path & " \ " & FileERT.FileName

i = FreeFile
Open "d1" For Input Shared As #i   <--error occurs here

Do While Not EOF(i)
 Line Input #i, textline    'reading each line
k1 = Mid(textline, 2, 2)
a1 = Right(textline, 2)



Loop

Close #i
End Sub

If i were to replace the line where error occurs with this:
Open "D:\sample_ERT\HC05C8A.txt" For Input Shared As #i

then it is ok. Directory is the same as d1.

Pls help!!
0
Comment
Question by:VivienW
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 11

Expert Comment

by:Steiner
ID: 8023712
Your problem are the spaces around "\". Use no spaces, only "\":

d1 = DirERT.Path & "\" & FileERT.FileName



Greets
Steiner
0
 

Author Comment

by:VivienW
ID: 8023755
I've taken away the spaces but it still does not work.Is it case sensitive?
Because as I step thru debug,d1=d:\sample_ERT\HC05C8A.txt
The only difference is the D: and d:. If yes, how do I change it to uppercase.This is because from the drive list it is in smallcase.
Thanks
0
 
LVL 1

Accepted Solution

by:
Belfry earned 200 total points
ID: 8023824
the problem is: you used quotation marks around "d1", kill the quotation marks, you'll succeed.

Open d1 For Input Shared as #i

try it, good luck!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:muskad202
ID: 8023849
the error is u are doing
---------------
Open "d1" For Input Shared As #i  
--------------------

when it should be
----------------------
Open d1 For Input Shared As #i  
-----------------------

no quotation marks !!!
0
 
LVL 2

Expert Comment

by:muskad202
ID: 8023851
oops belfry...we posted at around the same time  :)
0
 
LVL 3

Expert Comment

by:Rem
ID: 8023863
Open "d1" For Input Shared As #i '<--error occurs here
Open d1 For Input Shared As #i '<--error should not occur

0
 
LVL 3

Expert Comment

by:Rem
ID: 8023869
we all seem to post at the same time. LOL
0
 
LVL 11

Expert Comment

by:Steiner
ID: 8024237
Why didn't I see that?????
0
 
LVL 3

Expert Comment

by:Rem
ID: 8024294
;-))
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

572 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