Saving an array in a file

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I've posted questions about writing an array as a tabbed table, and then
making the table back into an array. Now I'm wondering if this is the only
way to save an array in a file. Is there a way to save the array as a "true"
array, so that the conversion steps aren't needed? I'm asking because the
"boundary condition" of a nearly empty file is a little messy.

[I didn't mean to ask about that last issue, but the problem is that in some
cases a file can contain one or two vbCr's and nothing else. I do a SPLIT
using the vbCr or vbCrLf character, and the code can do something unexpected.
I've added some klugy tests to prevent this, but I'm looking for a cleaner
solution.]

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200903/1
 
J

Jonathan West

christophercbrewster via OfficeKB.com said:
I've posted questions about writing an array as a tabbed table, and then
making the table back into an array. Now I'm wondering if this is the only
way to save an array in a file. Is there a way to save the array as a
"true"
array, so that the conversion steps aren't needed? I'm asking because the
"boundary condition" of a nearly empty file is a little messy.

[I didn't mean to ask about that last issue, but the problem is that in
some
cases a file can contain one or two vbCr's and nothing else. I do a SPLIT
using the vbCr or vbCrLf character, and the code can do something
unexpected.
I've added some klugy tests to prevent this, but I'm looking for a cleaner
solution.]

Ultimately, you have to know what can and cannot be within your data, and
then find some way of representing your array into a file. There are very
many different possible ways of doing this, and each has its own advantages
and disadvantages, which might or might not be critical depending on the
nature and quantity of your data.

Can you tell us a bit more about what you are trying to achieve?
 
C

christophercbrewster via OfficeKB.com

This involves both Powerpoint and Word, but the routines don't run at the
same time: Powerpoint writes slide titles in a file so that Word can get it.
The way I'd like to do it is to write a 1-D string array, with the element
subscripts representing slide numbers. (Currently this is written as a tabbed
table, with the numbers in the first column.) I think I need something like a
stream object, but I haven't seen how this is done in VBA.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200903/1
 
J

Jonathan West

christophercbrewster via OfficeKB.com said:
This involves both Powerpoint and Word, but the routines don't run at the
same time: Powerpoint writes slide titles in a file so that Word can get
it.
The way I'd like to do it is to write a 1-D string array, with the element
subscripts representing slide numbers. (Currently this is written as a
tabbed
table, with the numbers in the first column.) I think I need something
like a
stream object, but I haven't seen how this is done in VBA.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200903/1

You can define your own file format, and write direct to it using the Open
command to create the file, the Print # command to write text to it, and
Input # or Line Input# to read from it. Look up the Basic File I/O commands
in the Word VBA help.

Or you could decide to turn the data file into XML and use the one of the
Microsoft XML libraries for reading & writing the XML. You can access these
libraries by going to Tools References in the VBA editor, and attaching the
appropriate library to your project. You want one or other version of
"Microsoft XML". You would still need to define how you are going to
structure your XML, but it should all be fairly straightforward once you
have learned it. beware, the XML object model isn't available in the Word
VBA help, but if you do a web search for the relevant keywords, you will
find the necessary descriptions on Microsoft's MSDN site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top