Solved

Write to OLE embedded text file in Excel

Posted on 2011-02-11
5
473 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

770 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