Solved

Open File Names with Single Quotes in the File Name!

Posted on 2003-11-20
3
567 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now