Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to read data from binary file?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default How to read data from binary file?


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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to read data from binary file?

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
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.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default How to read data from binary file?



from

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

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

to

fileToOpen = "c:\temp\book1.xls"
Set fout = fs.CreateTextFile _
(fileToOpen, True)

fileToOpen = "c:\temp\book2.xls"
Set fin = fs.OpenTextFile(fileToOpen, _
ForReading, TristateFalse)

"Valery" wrote:

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import binary file and convert to HEX data Fan924 Excel Programming 2 September 25th 07 06:44 PM
Read Binary Dan Excel Programming 4 October 13th 05 04:42 PM
Solver returns non binary answer in binary constrained cells Navy Student Excel Worksheet Functions 6 September 1st 05 03:11 PM
read a Unix binary file Arnaud Boëlle Excel Programming 2 April 20th 05 09:24 PM
How can I read/write file with binary format??? NC Excel Programming 2 May 27th 04 09:35 AM


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"