Hi Pascal,

I'm glad you found the problem (specifying the whole path with Getfile)

 

With late binding you don't need to set a library reference.

If you don't set a library reference, the constants aren't defined. 

You can easily verify the values of the constants in the immediate window
like so:

? ForReading        ' Should indicate 1 per MSDN

? ForWriting        ' Should indicate 2

? TriStateUseDefault' Should indicate -2

 

If they are  defined, then you must have set a reference to the library, or
defined them yourself.

If you set a reference to the library, it is preferable to use early
binding, like so:

Dim fs As Scripting.FileSystemObject, f As Scripting.File, ts As
Scripting.TextStream

'.

Set fs = New Scripting.FileSystemObject

'.

If you want to use late binding, it's best to not reference the library at
all, in order to enjoy the main benefits of late binding (different library
versions breaking references on different computers).  Then you need to
either define the constants yourself or just use their numeric values when
you make calls to the library.

Asa

 

From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com]
On Behalf Of bpascal123
Sent: Wednesday, May 02, 2012 1:26 PM
To: excel-macros@googlegroups.com
Subject: Re: $$Excel-Macros$$ NAND memory flash-drive, writing from Excel to
a text file

 

Hi Asa,

 

I don't think there is any issues with constant, undefined variable types or
else, i do use option explicit for each module... I use late binding for
library references. The code that doesn't work is from msdn OpenAsTextStream
Method. I don't see any mistake I could have made. If yes the code should
not be working at all.

 

The first module testy generates an error with this line:

Set f = fs.GetFile("test2.txt") 'Error : "File not found" ...on removable
flash FAT32 filesystem...OK on NTFS HD

 

The second module testz works with any storage devices and file system
without any issue. As you can see, it uses:

Set txtfile = fso.CreateTextFile("Y:\test1.txt", True) 

The "True" parameter enables writing on the file (btw if you omit true, it
seems to overwrite a file without warning...)

 

If I understand from your previous post, Fat32 might generate some issues.
File system library seems to have been there for quite a while as vbscript,
and other scripts... so I don't see myself finding such a simple bug, given
that flash memory is widely available and used. To go further with this, I
should experiment this: format a usb key with NTFS and run the testy script
from above. I don't know what I will get but from what you say in your
previous post, it should then work or else it's a Vbscript bug...

 

 

Following this second discussion on storage technologies, I agree optical
fiber can transmit data the fastest. However I don't see flash memory last
for long since it was demonstrated not long ago that nothing we know about
can travel faster than light and flash memory is still accessing data using
semiconductors... After this my knowledge in this area becomes very weak...
:)

 

In my mind, what I would see possible to implement to store data is using
liquid crystal properties and access data using light to reach light speed
like with optical fibers but a laser is as fast as any other light, like
printer can come now with LED instead of laser beam... The thing is that
using LCD would always require some power to keep what is stored in memory
like with an LCD screen when off is blank or simply like with RAM... and
else I don't have any idea about the volume of data that can be stored using
liquid crystals. LCD currently store in very high definition 24 bit per
pixel...

 

Pascal Baro

-- 
FORUM RULES (986+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
 
----------------------------------------------------------------------------
--------------------------
To post to this group, send email to excel-macros@googlegroups.com

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to