Form Data into Template w/out Bookmarks!!

A

Al & Cay Grant

Hiya Folks,

I have a form that consists of mainly text boxs and have been using
Bookmarks
(which happen to be inside tables) to get the data inserted into the
template in the right place.

However I have introduced a multi-selectable listbox. The user can select
one or
more entry in the list box. The problem with this is that I can insert the
first selection
at a bookmark, but cant have a umlimited number of bookmarks, because each
time
the program is run different numbers of selections can be made (although its
not normally
more than about 4/5).

What I have done so far is to insert the string and add a vbCr & vbCr so
that when the
next string is inserted it has a blank line between them.

This method is a kinda ugly way to do things. What I was thinking would be a
better way
would be to use a table, which the first bookmark is in anyway.

The basic logic of the code would be something like

i = 1 to rows.selected
n = 1
activedocument.table(2).row(n).column(2).insertstring
table.rows.insert
n = n + 1
next 1

The other advantage to doing it this way is that I want to be able to format
certain parts of
each string. A string might look like;

Name: John Smith
Adress: 123 Any Street

And I want to format Name in bold and John Smith in Italics. I suppose if
they are repeated
for every string I could add them and format them at the time I insert the
new row in the table?

Thoughts? Sample code?

Cheers

- Al
 
W

Word Heretic

G'day "Al & Cay Grant" <bigal_nz@no$spam.remove.hotmail.com>,

store the table as autotext and insert that.


Hiya Folks,

I have a form that consists of mainly text boxs and have been using
Bookmarks
(which happen to be inside tables) to get the data inserted into the
template in the right place.

However I have introduced a multi-selectable listbox. The user can select
one or
more entry in the list box. The problem with this is that I can insert the
first selection
at a bookmark, but cant have a umlimited number of bookmarks, because each
time
the program is run different numbers of selections can be made (although its
not normally
more than about 4/5).

What I have done so far is to insert the string and add a vbCr & vbCr so
that when the
next string is inserted it has a blank line between them.

This method is a kinda ugly way to do things. What I was thinking would be a
better way
would be to use a table, which the first bookmark is in anyway.

The basic logic of the code would be something like

i = 1 to rows.selected
n = 1
activedocument.table(2).row(n).column(2).insertstring
table.rows.insert
n = n + 1
next 1

The other advantage to doing it this way is that I want to be able to format
certain parts of
each string. A string might look like;

Name: John Smith
Adress: 123 Any Street

And I want to format Name in bold and John Smith in Italics. I suppose if
they are repeated
for every string I could add them and format them at the time I insert the
new row in the table?

Thoughts? Sample code?

Cheers

- Al

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email (e-mail address removed)
Products http://www.geocities.com/word_heretic/products.html

Replies offlist may require payment.
 
A

Al & Cay Grant

The way I see it I can assign a whole table to autotext, but not just a few
cells.

The finaly formating should look something like

USERS: NAME: name1
ADD: street1

NAME: name2
ADD: street2

I dont really want USER repeated which could happen if I autotext the whole
table.

If I add the autotext to the template will it automatically be available
when the user
runs that template?

-AL
 
C

Cindy Meister -WordMVP-

Hi Al,

1) Personally, I prefer constructing the string, dropping it in a document

2) Building a table, step by step, as you propose, would be SLOW

3) How about a compromise: build a TAB-delimited string (or use any other
delimiter, doesn't have to be TAB). Dump this into a Word bookmark.range, then
use ConvertToTable to turn the delimited text into a table. You can then apply
any formatting you need to the table.
I have a form that consists of mainly text boxs and have been using
Bookmarks
(which happen to be inside tables) to get the data inserted into the
template in the right place.

However I have introduced a multi-selectable listbox. The user can select
one or
more entry in the list box. The problem with this is that I can insert the
first selection
at a bookmark, but cant have a umlimited number of bookmarks, because each
time
the program is run different numbers of selections can be made (although its
not normally
more than about 4/5).

What I have done so far is to insert the string and add a vbCr & vbCr so
that when the
next string is inserted it has a blank line between them.

This method is a kinda ugly way to do things. What I was thinking would be a
better way
would be to use a table, which the first bookmark is in anyway.

The basic logic of the code would be something like

i = 1 to rows.selected
n = 1
activedocument.table(2).row(n).column(2).insertstring
table.rows.insert
n = n + 1
next 1

The other advantage to doing it this way is that I want to be able to format
certain parts of
each string. A string might look like;

Name: John Smith
Adress: 123 Any Street

And I want to format Name in bold and John Smith in Italics. I suppose if
they are repeated
for every string I could add them and format them at the time I insert the
new row in the table?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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