PDA

View Full Version : MS Word Macro Help Please....



bellboy
12-18-2005, 10:08 AM
I'm creating a word document as a form/template. It will have a header and footer. It will also contain some text and a 5x5 table where users can input text. The width of the tables will be locked. If a user inputs a lot of text, a second page is created and it will contain the header/footer and the header of the table. no problem there... however,

The problem:

If a user is entering text on the last table of page one and a second page is created, only the table in which the user is entering text moves onto the 2nd page. I would like to have the 5x5 table created on all subsequent pages (including any text from the previous table on the previou page)

I hope that makes sense...:dunno


example:

I'm inputting text on the 5th row of the 1st page. I entered too much stuff and a second page is automatically created. a table was created on the 2nd page with only the header of the table and the last row of the 1st page...and that's it. If that occurs, I would like an additional 4 empty tables on the 2nd page to enter text. This should occur for all subsequent pages created after the first one.

I hope this helps... Thanks

mdmackillop
12-18-2005, 10:31 AM
Hi Bellboy,
Welcome to VBAX.
I'm not entirely clear about
I would like to have the 5x5 table created on all subsequent pages (including any text from the previous table on the previou page)

Can you post a sample of how it should appear on completion? To post a file, zip it and attach to your posty using Go Advanced and Manage Attachments.
Regards
MD

bellboy
12-18-2005, 11:33 AM
Hi,
Thanks for the quick response. I'm attaching two word examples (1 & 2)

example 1 contains the form in its original state with a table. The first two rows of the table are pretty much templated and will continue on all pages. The next 5 rows of the table are for the users to enter text. I provided some text in the 4th row. keep entering text in my example row to see the issue.

Example 2 is what i wish would occur. As a user enters enough text (in any row of the table) where a 2nd page is created, I would like the 2nd page to continue with the text from the previous page and I would like an additional "new table" created. (never to exceed more than 5 tables per page).

... and it would be nice to maintain the "comment" section in each page.

Wow, the more I read this, the more I'm getting confused...

I hope this helps.

Thanks!

fumei
12-18-2005, 09:14 PM
Not do-able. At least not as you describe you want it to be.

1a) The Comments table is a separate entity. It will be pushed, simply because you are expanded the prior table.

1b) Because it is a separate table, you can not leap frog over it, and maintain the prior table. The prior table can, and doesm continue header rows for the expanded table. But it will NOT leap frog over the Comments table.

2. You are asking for additional rows BECAUSE it expanded into the next page. The table expansion is dynamic. There is no way to have it automatically create new rows. There IS a way to run code to check conditions, and then create new rows, but it will not do it automatically. You would have to write and run code.

The Comment table, though, you are stuck. It will not leap frog. The Comment table is AFTER the first table. Period. You can not have a discontinuous table.

fumei
12-18-2005, 09:15 PM
You may have to reconsider some design elements.

First of all, why do you want the additional rows??

bellboy
12-19-2005, 09:25 AM
Hi Gerry,
Thank you so much for your feedback. I certainly will have to reconsider the design. Perhaps I can include a column for "comments".

As far as why I want additional rows.... I want users to have the flexability of inputting as much text as needed into these "controlled" forms, while not chaning the format.

Thanks again!

P.S. Can you recommend any good books for VBA macros? I've ordered the following: Absolute beginners guide to VBA (for office apps)...

fumei
12-19-2005, 11:45 AM
As far as why I want additional rows.... I want users to have the flexability of inputting as much text as needed into these "controlled" forms, while not chaning the format.

Sorry, but that does not make sense to me. I do not understand what that means. So they input more text...yeeessssss? And the problem is???

Perhaps you need to rethink using tables. Perhaps you could have an "Insert Comment" command button that allows them to inset a separate row (even formatted differently to show it as a comment row) with comments regarding the previous row.

The question is not what you CAN do...but what you want to do. That requires thinking not just about format, but design of gathering information, displaying information, and...if applicable, retrieving information.

I would recommend two books, both of which are older now, but still very very useful.

Word 2000 Developer Handbook. While it is Word 2000, 99% of the object model is still applicable. It has excellent design consideration and LOTS of examples of code.

VBA Developer Handbook. Ditto.

Both are published (were published) by Sybex. I doubt if they are still actively in print, but that is good - you can find 'em in second hand computer books stores for cheap.

Between those two, and liberal use of the F1 key (a.k.a. HELP), and dropping posts to here...hey, you be laughing...well with some work on your part.

bellboy
12-19-2005, 12:13 PM
[QUOTE=fumei]Sorry, but that does not make sense to me. I do not understand what that means. So they input more text...yeeessssss? And the problem is???

Perhaps you need to rethink using tables. Perhaps you could have an "Insert Comment" command button that allows them to inset a separate row (even formatted differently to show it as a comment row) with comments regarding the previous row.QUOTE]

Hi Gerry,

My goal is to create a form that is controlled...which means the structure of the form must never change (i.e., header, footer, certain identifying text not in a table, and table widths) regardless of how many pages a user needs.
When a user inputs text and a second page is created, I want the user to see the original structure as the 1st page.

However, I do like your idea on having command buttons to insert a "Comments:" section. Let me see if I understand what you're stating...

Is it possible to have a form with a command button that allows a user to insert a table to input text? over and over again, regardless of the number of pages?

Thanks!

mdmackillop
12-19-2005, 12:22 PM
Hi Bellboy,
Have you thought to use Autotext for the user to create your subsequent pages
Regards
MD

TrippyTom
12-20-2005, 09:38 AM
Have you considered using an Adobe Acrobat form instead? They are MUCH easier to create and maintain. If you have Acrobat Writer it's the only way to go!

Specifically, text fields can auto-adjust the font size based on how much the user types - so your frame does not expand. Perhaps this would help?

fumei
12-20-2005, 09:54 AM
Tables have a structure. That structure is primarily this: if you put more stuff inside the table it does ONE thing. It gets bigger.

Sorry, but that is what tables DO. That is what tables are for.

You need to rethink. When you state user "input" text...in fact they are not doing anything of the sort. They are typing text. If they are typeing text inside a table, then it is consider more stuff. More stuff makes the table get bigger. The cell expands. Period. There is nothing you can do about it, at least automatically. Otherwise it would destroy the point of having a table.

Try and realixe what you are asking. You have a PAGE with a structure - a table, header, footer blah blah. User types in text INSIDE the table, the table expands to accomodate this - nice table, polite table, good dog. If it can no longer be contained on the page the table expands on to the next page. ALL the other stuff does not...and why should it? The header/footer other stuff...nope, they are not pulled along because there is no direct linkage between them. They are a design element, not a structural one.

Remember, unless you are using 2003, there is NO such thing as a page. There are NO pages in Word - prior to 2003. There is NO page object. This is hugely significant.