Appeding user data to the end of excel file

B

Bharathi mohan

Hi friends,

I wrote a macro such that it will append some data at the end of th
excel file(I opened the file in binary mode and wrote the content)

The sample code will be like this

Open filename For Binary Access Write As #1
If startpos = 0 Then
startpos = LOF(1)
End If

Put #1, startpos, "my data"
Close #1

After closing the file and opening it in Notepad the data is stil
there.

But if i reopened it in excel and closed the file, the data is gone.
Excel overwrites the user defined data.

Assist me in keeping my data persistent so that i will retrieve th
contents and process it
 
C

Chip Pearson

You can't just write to Excel files using VBA's file write
procedures. Excel files are internally extremely complicated, and
VBA doesn't support the data types required to manipulate them
directly. You should use Excel itself to modify Excel files.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Bharathi mohan >" <<[email protected]>
wrote in message
news:[email protected]...
 
T

Tom Ogilvy

Some references:

http://support.microsoft.com/?id=253338
INFO: Office Developer Samples and Tools Available for Download

http://support.microsoft.com/?id=260410
OFF2000: Microsoft Office 2000 Automation Help File Available



--
Regards,
Tom Ogilvy

Chip Pearson said:
You can't just write to Excel files using VBA's file write
procedures. Excel files are internally extremely complicated, and
VBA doesn't support the data types required to manipulate them
directly. You should use Excel itself to modify Excel files.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Bharathi mohan >" <<[email protected]>
wrote in message
 
J

Jamie Collins

...
You can't just write to Excel files using VBA's file write
procedures. Excel files are internally extremely complicated, and
VBA doesn't support the data types required to manipulate them
directly. You should use Excel itself to modify Excel files.

Another option is to use the Microsoft OLDB Provider for Jet i.e. ADO
and SQL to write data to an Excel file. Using SQL's INSERT INTO syntax
will append the new row to the bottom of the Excel range.

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top