Write to OLE embedded text file in Excel
Posted on 2011-02-11
This is definitely a 500 point question.
I've written a large "object-oriented" application in Excel 2003 vba and this includes writing a lot of settings to a text file. I read and write the text files line by line and I'm quite happy with the way this works.
HOWEVER: One of the main incentives for coding this project in VBA was that the application should be self-contained, i.e. just the *.xls-file and no extra *.txt-files or any other "tag-alongs" to keep track of. So I have to get rid of the separate text file somehow. As far as I can see, there are two options:
1) Use a multiline text box instead: This, however, requires that i can perform read/write operations on the text box in a similar manner as I do with a text file. This does not seem to be possible and I don't particularly want the hassle with chopping up a huge string in substrings containing a lot of special characters and so forth.
2) Embed the text file in my spreadsheet as an OLEobject. This works, but how the h*** do I access it programmatically for read/write operations in VBA without opening it for the user to see? Working with such embedded OLEobjects in VBA seems to be a nightmare. The .open and .verb methods just open the damned file for plain view.
I would appreciate any help here :o). I can't find anything useful on the internet.