compile master document from other document pieces

J

jazzaus

I am building a custom document building routine.
My plan is to present a form to the user where they select several
variables. From these selections the code can determine the contents of the
document that is to be created.
The parts of the main document will be large sections of text relevant to
the subject. I thought that I could either use 1 big document with sections
having the sections tagged with the variable values so that I could get the
entire sections needed into a new document. Another option would be to have
separate documents for each of the sections and have the documents tagged
with the variables. I then could compile the main document from all of the
other documents with successive insert file commands.
Having 1 big document would be an advantage because I would not have to
worry about the network location of subdocuments.
I am kind of hung up on the tagging issue. What methods do you know of that
give some custom attribute values that can be stored with a section or with a
document that I could retrieve via VBA to determine with sections/documents I
need to get to compile the new master document?

An example might be variable 1 can have a value of a or b, variable 2 can
have a value of blue or green.
When a user selects variable 1 as "a" and variable 2 as "green" I need to
add documents one and six and eight.
When a user selects variable 1 as "a" and variable 2 as blue I need to add
documents two, four and eight together to make the new master document.
The more variables that get added the more combinations will exist but each
subsection or subdocument will have the variables filled out. Document one
may have a variable 1 value of "a" while document eight may have a variable 1
value of "a" AND "b" so that it will be included no matter what variable 1 is.
Any suggestions are welcome.
Thanks,
Joel
 
G

Greg Maxey

You could use variables and then process as follows:

Sub ScratchMacro()
Dim oVars As Variables
Set oVars = ActiveDocument.Variables
Select Case True
Case oVars("1").Value = "a" And oVars("2").Value = "Blue"
MsgBox "Your code to build master using docs 1, 6 and 8"
Case oVars("1").Value = "a" And oVars("2").Value = "Green"
MsgBox "Your code to build master using docs 2, 4 and 8"
End Select
End Sub
I am building a custom document building routine.
My plan is to present a form to the user where they select several
variables. From these selections the code can determine the contents
of the document that is to be created.
The parts of the main document will be large sections of text
relevant to
the subject. I thought that I could either use 1 big document with
sections having the sections tagged with the variable values so that
I could get the entire sections needed into a new document. Another
option would be to have separate documents for each of the sections
and have the documents tagged with the variables. I then could
compile the main document from all of the other documents with
successive insert file commands.
Having 1 big document would be an advantage because I would not have
to
worry about the network location of subdocuments.
I am kind of hung up on the tagging issue. What methods do you know
of that give some custom attribute values that can be stored with a
section or with a document that I could retrieve via VBA to determine
with sections/documents I need to get to compile the new master
document?

An example might be variable 1 can have a value of a or b, variable 2
can have a value of blue or green.
When a user selects variable 1 as "a" and variable 2 as "green" I
need to
add documents one and six and eight.
When a user selects variable 1 as "a" and variable 2 as blue I need
to add documents two, four and eight together to make the new master
document.
The more variables that get added the more combinations will exist
but each subsection or subdocument will have the variables filled
out. Document one may have a variable 1 value of "a" while document
eight may have a variable 1 value of "a" AND "b" so that it will be
included no matter what variable 1 is. Any suggestions are welcome.
Thanks,
Joel

--
Greg Maxey

See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.

"It is not the critic who counts, not the man who points out how the
strong man stumbles, or where the doer of deeds could have done them
better. The credit belongs to the man in the arena, whose face is
marred by dust and sweat and blood, who strives valiantly...who knows
the great enthusiasms, the great devotions, who spends himself in a
worthy cause, who at the best knows in the end the triumph of high
achievement, and who at the worst, if he fails, at least fails while
daring greatly, so that his place shall never be with those cold and
timid souls who have never known neither victory nor defeat." - TR
 
J

jazzaus

Thanks for you quick response. This looks like it will do what I need.

Variables are per document. Is there something synonymous with sections? (do
sections have a variable associated with them?)

When a user opens the form from the template I will iterate through my
available variables and populate the multiselect list boxes on the fly to
accomodate newly added documents variables. Is it possible to retrieve a
documents variables without opening the document?
 
M

Manfred F

These <tagging> kind of issues can be traced back to two basic issues:
1) identify the range that shall have the tag
2) assign the metadata (tag) to it.

To identify the range, You have different possibilities: use separate
documents, use bookmarks, sections e.g., I once solved a chapter masking
issue using chapters for this.
To assign the metadata, Your options depend on the solution for 1). For
separate documents, You can use variables or custom document properties. For
bookmarks, sections, chapters, this doesn't work, because these properties
are document-based.
To assign metadata to a certain text range, You might think about using
hidden text. I preferred adding comments, I considered hidden text to be too
fragile. I set for these technical kind of comments a certain author and user
initials and gave its content a special structure to distinguish it from
standard comments.

Regard
Manfred
 

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