View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Valery Valery is offline
external usenet poster
 
Posts: 20
Default How to read data from binary file?

Joel Thanks !
Help me please one more
I need the open file without dialog box
it's possible ?
in second i would read data from binary file , put in cell 100 byte in some
cell on the sheet And after unload 100 to a new binary file from cell

Thanks for you time.

"Joel" wrote:

You don't have to put any data into a worksheet. You can open two files and
move data from one file to the second file

Sub fixevents()
Const ForReading = 1, ForWriting = 2, _
ForAppending = 3

Set fs = CreateObject("Scripting.FileSystemObject")



fileToOpen = Application _
.GetOpenFilename("Binary Files (*.bin), *.bin", _
Title:="Read File")
If fileToOpen = False Then
MsgBox ("Cannot Open File - Exiting Sub")
End If

Set fin = fs.OpenTextFile(fileToOpen, _
ForReading, TristateFalse)

fileToOpen = Application _
.GetOpenFilename("Binary Files (*.bin), *.bin", _
Title:="Write File")
If fileToOpen = False Then
MsgBox ("Cannot Open File - Exiting Sub")
End If


Set fout = fs.CreateTextFile _
(fileToOpen, True)



Do While fin.AtEndOfStream < True
readdata = fin.Read(Characters)
fin.write readdata

Loop
fin.Close
fout.Close
End Sub


"XP" wrote:


A tutorial at this web page might get you started, or at least be helpful:

http://www.developerfusion.co.uk/show/85/1/

Hope this helps.

"Valery" wrote:

Hello Guys!
Such a question to you

I have a binary file. I need to get from this file data in 100 byte to cell
and after I need to create a new binary empty file and unload it received
data from the first binary file.

Thanks for you time.
Regards Valery.