T
Top Spin
I would appreciate some ideas or suggestions on the overall logic or
structure of a little VBA application I would like to have written.
In my business, I have various services I offer to clients. Let's call
them service A, B, C, etc.
These services also have a few general attributes such as
"confidential"/"non-confidential" or "court-ordered"/"not
court-ordered".
Right now, I have about 10 different contract templates (Word) for
various clients, such as "Service A, confidential", or "Service C,
court-ordered, not confidential", etc.
Most of the clauses in these contracts are the same or very similar. I
would like to consolidate all of the templates into one master
template containing all of the clauses that might be needed by any
type of service and then write a macro to delete the clauses that are
not needed for the type of service at hand.
My first idea was to put some type of delimiter into the template just
before each clause to indicate which types of services it applies to
so the macro would know which clauses to delete and which to keep.
So I need some syntax for the delimiters that would be unique and
simple to use. My first thought was something like:
/a/c/f
which would mean: include the text that follows in contracts for
services A, C, or F. The template might look something like this:
/a/b
Text of clause to be used for type A and B services.
/c
Text of clause to be used only for type C services.
/all
Text of clause to be used for all services.
The macro would scan for delimiter lines, then include or exclude all
of the text up to the next delimiter line depending on whether the
service type being processed matched the delimiter or not.
When I started putting the delimiters into the template, I quickly
realized that there a quite a few clauses that apply to all services,
but they are slightly different for one or two types. What I want for
them is a way to say: use this clause for Service A, this for service
B, and this for all the others. For example:
/a
Text of clause to be used for type A services.
/b
Text of same clause to be used for type B services.
/"all the others (not a and not b)"
Text of same clause to be used for all services other than A or B.
It's that "all the others" that my simple syntax doesn't accomodate.
I know I could implement a complete boolean syntax like
/(^a)&(^b)
Text of same clause to be used for all services other than A or B.
But I would prefer not to write a general-purpose parser. I would also
like to avoid repeating the "a" and "b", in case I add a special
version for type C so I won't have to remember to change "/(^a)&(^b)"
to "/(^a)&(^b)&(^c)".
I thought about introducing "groups" of clauses and have the macro
keep track of which types have been used so I could have an "all the
rest" clause at the end. Something like this:
//group
/a
Text of clause to be used for type A services.
/b
Text of same clause to be used for type B services.
/e
Text of same clause to be used for type E services.
/
Text of same clause to be used for all services other than A, B, or E.
//end
The //group would start a group. The macro would remember that it had
seem clauses for A, then B, then E, so when it encountered the null
"/", it would include that text for all tyoes that it had not seen.
The "//end" would close that group.
It there something simpler and more elegant?
Thanks
structure of a little VBA application I would like to have written.
In my business, I have various services I offer to clients. Let's call
them service A, B, C, etc.
These services also have a few general attributes such as
"confidential"/"non-confidential" or "court-ordered"/"not
court-ordered".
Right now, I have about 10 different contract templates (Word) for
various clients, such as "Service A, confidential", or "Service C,
court-ordered, not confidential", etc.
Most of the clauses in these contracts are the same or very similar. I
would like to consolidate all of the templates into one master
template containing all of the clauses that might be needed by any
type of service and then write a macro to delete the clauses that are
not needed for the type of service at hand.
My first idea was to put some type of delimiter into the template just
before each clause to indicate which types of services it applies to
so the macro would know which clauses to delete and which to keep.
So I need some syntax for the delimiters that would be unique and
simple to use. My first thought was something like:
/a/c/f
which would mean: include the text that follows in contracts for
services A, C, or F. The template might look something like this:
/a/b
Text of clause to be used for type A and B services.
/c
Text of clause to be used only for type C services.
/all
Text of clause to be used for all services.
The macro would scan for delimiter lines, then include or exclude all
of the text up to the next delimiter line depending on whether the
service type being processed matched the delimiter or not.
When I started putting the delimiters into the template, I quickly
realized that there a quite a few clauses that apply to all services,
but they are slightly different for one or two types. What I want for
them is a way to say: use this clause for Service A, this for service
B, and this for all the others. For example:
/a
Text of clause to be used for type A services.
/b
Text of same clause to be used for type B services.
/"all the others (not a and not b)"
Text of same clause to be used for all services other than A or B.
It's that "all the others" that my simple syntax doesn't accomodate.
I know I could implement a complete boolean syntax like
/(^a)&(^b)
Text of same clause to be used for all services other than A or B.
But I would prefer not to write a general-purpose parser. I would also
like to avoid repeating the "a" and "b", in case I add a special
version for type C so I won't have to remember to change "/(^a)&(^b)"
to "/(^a)&(^b)&(^c)".
I thought about introducing "groups" of clauses and have the macro
keep track of which types have been used so I could have an "all the
rest" clause at the end. Something like this:
//group
/a
Text of clause to be used for type A services.
/b
Text of same clause to be used for type B services.
/e
Text of same clause to be used for type E services.
/
Text of same clause to be used for all services other than A, B, or E.
//end
The //group would start a group. The macro would remember that it had
seem clauses for A, then B, then E, so when it encountered the null
"/", it would include that text for all tyoes that it had not seen.
The "//end" would close that group.
It there something simpler and more elegant?
Thanks