Append to open CSV

C

CY459

I currently have my equipment software send information to
a CSV file. It will continue to append to the CSV for as
long as I wish. I would like to have the file open in
Excel while appending to the CSV file so that I can see
the results of each measurement in real time.
 
G

GB

CY459 said:
I currently have my equipment software send information to
a CSV file. It will continue to append to the CSV for as
long as I wish. I would like to have the file open in
Excel while appending to the CSV file so that I can see
the results of each measurement in real time.

I have never actually done this, but hopefully someone with more experience
will correct my mistakes, and it's a few hours since you posted without any
response.

You can open a file in VBA with shared access. You probably also need to
make sure that your logging software also allows a file share on the file.

This is what the VBA help file says:


Enables input/output (I/O) to a file.

Syntax

Open pathname For mode [Access access] [lock] As [#]filenumber
[Len=reclength]

The Open statement syntax has these parts:

Part Description
pathname Required. String expression that specifies a file name¾may include
directory or folder, and drive.
mode Required. Keyword specifying the file mode: Append, Binary, Input,
Output, or Random. If unspecified, the file is opened for Random access.
access Optional. Keyword specifying the operations permitted on the open
file: Read, Write, or Read Write.
lock Optional. Keyword specifying the operations permitted on the open file
by other processes: Shared, Lock Read, Lock Write, and Lock Read Write.
filenumber Required. A valid file number in the range 1 to 511, inclusive.
Use the FreeFile function to obtain the next available file number.
reclength Optional. Number less than or equal to 32,767 (bytes). For files
opened for random access, this value is the record length. For sequential
files, this value is the number of characters buffered.
Remarks

You must open a file before any I/O operation can be performed on it. Open
allocates a buffer for I/O to the file and determines the mode of access to
use with the buffer.
If the file specified by pathname doesn't exist, it is created when a file
is opened for Append, Binary, Output, or Random modes.
If the file is already opened by another process and the specified type of
access is not allowed, the Open operation fails and an error occurs.

The Len clause is ignored if mode is Binary.

Important In Binary, Input, and Random modes, you can open a file using a
different file number without first closing the file. In Append and Output
modes, you must close a file before opening it with a different file number.
 

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