Solved

Write to OLE embedded text file in Excel

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

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 …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

807 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