I think we need some clarification on this thread. As far as I see the solution does only work for a specific class of devices or a special kind of communication: This is if we have a request-response model. The application writes something on the serial port and can assume that the response will come back from the device in the next 5 or 10 seconds. In the example in thread
http://user.services.openoffice.org/en/ ... 20&t=31686 the
Wait is required to fine tune this. If the application starts reading too early the stream or filehandle that was opened with the
oFSO.OpenTextFile() will either block or return EOF depending if it reads synchronously or asynchronously (overlapped is the terminology for this in the Win32 WriteFile API).
Actually "blocking" on the file handle would not be too bad as this would only block until there are some bytes to read from the serial port. But it seems that the OpenTextFile method from the Windows Scripting Host object is not tailored to wait a "long" time for data on a file handle. And I am not suprised about this, because the method name
OpenTextFile tries to tell us that it wants to be used for text files and not for low level (aka serial port) file access.
If you start the reading operation too late, you might have already lost some data, because the size of the buffer that the OS uses to handle the data bytes that come in on the serial port limited.
Sure if you experiment and test a bit you can tune the delay parameter in a way that your app would work in 99% of the time. But again this is only for the request-response communication type. If you have a different device (maybe a desktop phone or a DCF radio clock) that can send data on the serial port at any time you will need to poll the port or need to use an intermediate layer that fires events (to your app) and it might well be that the OP had such a case in mind.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.