Solved

Write to OLE embedded text file in Excel

Posted on 2011-02-11
5
470 Views
Last Modified: 2013-11-05
Hello there

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.

Best regards,
Einar
0
Comment
Question by:EISTO
  • 3
  • 2
5 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34868955
If they are settings, why not store them in document properties, defined names, or even a hidden worksheet? (or really anything but an embedded text file!)
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34868956
Oh, or the registry, depending on what the settings are?
0
 

Author Comment

by:EISTO
ID: 34868998

Hi, Rorya

Document settings? I'm afraid I don't know what you mean by this.
The "settings" are both settings for my objects and data to be kept between sessions in general. I would very much prefer to avoid using a spreadsheet unless I absolutely have to since this means entirely rewriting the methods for reading/writing settings.

Einar
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 34869043
You can add custom properties to a workbook in addition to its built-in ones like author, company, subject etc.
For data that needs storing I would probably use defined names or the registry.
0
 

Author Closing Comment

by:EISTO
ID: 34869670
Ok. Seems that I will have to admit defeat and rework my functions since they store arrays as well as other data. Thanks for showing me custom document properties, though. Although rather limited in flexibility they might come in handy later on.

Einar
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now