Jumat, 08 Juni 2012

[ExcelVBA] ReSOLVED: Opening a CSV file and populating cells just like Excel does

 



--- In ExcelVBA@yahoogroups.com, Derek Turner <g4swy@...> wrote:
> Freefile gets the next available file number …people telling you that this is the proper way …
> hard coded magic numbers.

Understood. Using your own (Open as #) FileNumbers vs. the system's sequential numbers.

> Close by itself will close all open files (files opened with the 'Open' statement). Close 66 does not error if #66 is already closed or never opened.

That is what I am familiar with in good ol'-fashion Basic. If you saw my CAT Workbooks, I use API calls into Kenel32 and system generated handles are used.

AND... from the "Once You Understand it, the Initial Guidance Makes Sense" department (:-):

> Note that the keyword 'Close' is both a VBA statement and also a method in the Windows Filesystem object. Do not confuse them.

Ahhhh … If I knew how to 'not confuse' them …

Uh… That was the issue. After trying several different creative, OO looking syntaxes, syntaxi, syntaxum…? I worked my way to:

Windows(FileNameOnly).Close

Where FileNameOnly = StrReverse(Split(StrReverse(sFullFileName), "\")

… And all is well in the universe. ('Windows Object' was the clue I missed). After 8-10 years playing this OO syntax starts to maker sense, sort of.

Thanks profusely, Steve, K9DCI

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar