Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Work with Variable Content Documents? 1

Status
Not open for further replies.

Genimuse

Programmer
May 15, 2003
1,797
US
I'm pretty inexperienced with VB, but have written enough small applications to not be an utter newbie.

However, I can't seem to figure out how to write (create) and read "documents" for my applications that contain a variety of things.

In my case I'd like to be able to create documents for my application that contain, at the very least, a database, some text, and a variety of graphics (as added to the document by the user).

I understand how to read and write all of those things as separate files, but I don't follow how you "lump" them all together into a single document file.

(Sorry if this is a newbie question... I searched the archives here and did my best with my Google-fu, but can't seem to find the right words to search for.)

Thanks in advance.
 
You can store the text in the database, as far as the graphics go, you can store the path to the graphic's file(s) in the database and load the picture(s) from the path(s)

Answer your question?
 
Unfortunately, not really.

Imagine a Word document. The file has a format that contains the text of the document and the graphics that you import. When you send someone a Word file you don't have to send them all of the graphics you used, too, because they've become part of the file.

Similarly I need my eventual users to be able to send each other a single file that contains all of the items used in the document.

I assume that Word uses some kind of fairly complex custom format that it reads and writes, possibly with some kind of "directory" at the beginning that tells it about the contents of the file, or possibly just as one long sequential stream that has embedded markers saying something like "the next 4123 bytes are a bmp" or something.

I can imagine how to write a ton of code that does the same thing, but it seems like it's going to get really tricky, like trying to figure out how to tell ADO where the database is in the file (and then letting it do it's normal thing? Man, that doesn't seem like it's going to work).

I can imagine some kind of "packing and unpacking" thing that I'd do every time someone saved or opened a file, writing a bunch of temporary files out and then cleaning them up later, but that seems pretty ugly, too.

I guess I'm just hoping that folks have done this in VB before without writing a ton of custom code to read and write their own complex, proprietary format, and without resorting to using a ton of space in the Temp directory.

If I need to do the "pack and unpack to the Temp directory" thing, is there a simple way to know the path of the Temp directory on a given machine? I'm know sometimes it's C:\Windows\Temp, and other times C:\WINNT\Temp, and many other times the drive letter is something entirely different (I know that G: is the boot drive on my development machine here), and I'm sure other times the paths are different from that, etc. Is there some kind of "virtual" way of looking for it?

Thanks very much.
 
Word uses something called Structured Storage (sometimes also known as Compound Document). It is possible to create your own Structured Storage documents, although it isn't straightforward in VB. I've toyed with this in the dim and distant past burt never got anything solid working
 
Bingo, those are the magic words I'm looking for. Thanks very much!

Now if only I can find a VB wrapper for the API. One guy seems to have written one, but his site is no longer in existence.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top