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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing Document Variables and Arrays (Hard one) 1

Status
Not open for further replies.

faztech

Programmer
May 21, 2001
22
AU
Hi,
I have designed a word template that builds a travel program booklet. The user can select the type of pages and the number of each and then the program will build each of the pages then create a contents page. The problem I am having is that when a page is created its name is stored in an array so the system knows what pages are in the booklet so it can perform tasks such as duplicate and update. If the user creates the booklet then saves and closes, the array (of course) is unloaded. So the next time the user opens the document and tries to duplicate it does not know what pages are there. I have been trying to use the custom document properties to save the array (as a concatenated string) and also some other boolean values but it doesnt like it. Anyone got any ideas i am dry out of them

Thanks for your help

Faztech
:)
 
reference the excel object


create an excel spreadsheetdump the the array to the spreadsheet save as c:\temp\lastuserarrray.xls


then next time they goto us eit get the array from teh spreadhseet

if you need example of the code to do this give us a shout and ill post some


 
Thanks chance1234 I will have a go and if I run into any troubles I will give you a yell. I am trying to use the custom document properties at the moment but it doesnt look like it will work. Also looking at the possibilities of a .ini class module file to save and retrieve the data.

Thanks again

Faztech
;-)

 
I've only messed with WORD Document Variables. In Word, any Variable set to "" (0 length string) becomes undefined, i.e. deleted from the set of Variables.
Try something like this.
Code:
Sub StoreArrayStr(strName as string,aryStore() as string)
'* Store string array
Dim J As Long
J = Ubound(aryStore)
ActiveDocument.Variables(strName & "_Ubound") = Cstr(J+1))
For I = 0 to J
    ActiveDocument.Variables(strName & "_" & Cstr(I+1)) = aryStore(I)
Next
'------------
Sub RetrieveArrayStr(strName as string,aryStore() as string)
'* Store string array
'* aryStore must be Dynamic array
Dim J As Long
J = Clng(ActiveDocument.Variables(strName & "_Ubound")-1
Redim aryStore(J) 
For I = 0 to J
    aryStore(I) = ActiveDocument.Variables(strName & "_" & Cstr(I+1))
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top