Solved

Open File Names with Single Quotes in the File Name!

Posted on 2003-11-20
3
569 Views
Last Modified: 2010-05-01
I have a that gets sent to a Main Frame system which requires the file name to have single quotes on each end of the file.

Example:
'PSDH.XM.M2.P900.CGS.DXMEXT00'

This is a text file you can view in Notepad, and I'm trying to write a program that opens the file and verifies the date in the header record before it gets sent to the Main Frame to ensure the operator is sending the correct file.

I'm unable to open the file because the command doesn't work:

sFilePath = "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00'"

Open sFilePath For Output As lFileNum

The sFilePath ends up looking like this in debug: "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00"'

Any ideas on how I can read this file in to verify the header record???

Thanks,
smithmrk
0
Comment
Question by:smithmrk
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Z_Beeblebrox earned 500 total points
ID: 9790284
What exactly is the problem? I tried something similar here and it worked fine. Why are you opening the file for output if you want to read the file header?

Zaphod.
0
 

Author Comment

by:smithmrk
ID: 9790398
Ok Your Right I had Output instead of Input!

However now it jumps right to Close File??
Error 62 Past End of File?

I only want the first line of the file anyway.
Let me know what happens on your end.

Thanks!

sFilePath = "c:\'PSDH.XM.M2.P900.CGS.DXMEXT00'"

On Error GoTo ErrorHandler

lFileNum = FreeFile

Open sFilePath For Input As lFileNum

Do Until EOF(lFileNum) = True
    Line Input #lFileNum, sFileLine
    sFileDate = sFileLine
    Exit Do
Loop

Close #lFileNum

0
 

Author Comment

by:smithmrk
ID: 9790442
OK I'm a Dumb Ass!

When I had the Output Statement instead of the Input Statement I over wrote my file with nothing in it.

Therefore once I changed the Output to Input using the same file there was nothing to read in.

Dumb Ass!

Long Day, but thanks for your help and pointing out my Output vs Input statement.  I was so sure it had to do with the signal quote thing.

You guys rock!
Thanks again,
smithmrk
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 59
Concatenate 2 userform comboboxes to a userform text box 4 62
VBS file using code from 2nd file (txt or vbs) 4 36
message box in access 4 46
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…

777 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