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

MS Word Forms Questions

Status
Not open for further replies.

sivaafi

Technical User
Oct 8, 2004
2
US
I am creating a form document template and have 2 questions.
1) Is there a way to insert an attachment on a form document? The form will be protected, but would like to have ability to insert an attachment.
2) I am looking to add in a row into the form based on input.
The form fields exist in a Word table.
What I would like to do is, based on input into the first form field, insert a new row copying the form fields also.
Example:
The table contains 3 columns. On the 3 columns, I have 3 entries for the form: Text, Drop Down List, and Text formatted to date.
When the user enters something into the first Text feild, I want to create a new row.
TIA
 
To use the form you have to protect it for forms. This disallows the adding of a row.

You need an OnExit macro for the formfield that is going to fire the code, to make a new row. It first must unprotect the document, make the row, then protect the document again, so the form will work again.

Question though...

Do you want the new row to also contain new formfields? In which case, you need the OnExit to make new formfields as well.

Regarding the attachment, you will have to be more clear. What do you mean "insert an attachment"? Does that mean insert a file from your local drive that was an attachment? Does it mean you want to send the current document as an attachment?

What are you trying to do? You can not attach something to a document.

Gerry
 
As far as inserting an attachement, I would like the ability to select a document from the hard drive and insert it as an attachment, like a .txt file.
Thanks for the quick response.
 
Hi,

If you're prepared to forego folder browsing functionality, you could use a formfield to solicit the filename and path. Then use an INCLUDETEXT field to link to the 'attachment'. This would insert that file into the Word document.

For example, Say you have a formfield that sets a bookmark named 'Source' and the formfield is set to calculate on exit. To implement the INCLUDETEXT field, select where you want the inserted data to start and press Ctrl-F9 to create a set of field braces, and type between them thus:
{INCLUDETEXT "" \!}
Between the double quotes, press Ctrl-F9 again to insert a cross-reference to your formfield's bookmark, thus:
{INCLUDETEXT "{Source}" \!}

Now, if you protect the document for forms, you'll get a message like "Error! Cannot open file." because the filename hasn't yet been defined. If you want, you can suppress that message with more field coding, so that your filed ends up with two copies of the INCLUDETEXT field and the error message inside an IF test:
{IF{INCLUDETEXT {Source} \!}= "Error! Cannot open file." "" {INCLUDETEXT {Source} \!}}

The one final point to note is that, when you insert another document via an INCLUDETEXT field, all styles shared by the two documents are applied to the source document.

Cheers
 
I would like the ability to select a document from the hard drive and insert it as an attachment, like a .txt file.{/quote]

This seems to be appear a lot recently.

You can not attach a file to a document.

You can insert the contents, using macropod's suggestion. Ther are other methods for doing a similar job. You can insert a hyperlink to another document, and even to a specific place in that document. But it is NOT attached. It is NOT attached in macropod's suggestion either. In either case, Word goes looking for the file.

If you insert the file (Insert > File) you are inserting the contents. As macropod mentions, the styles are the source file styles. Although be careful here, earlier versions act differently than later ones.

So again, what do you actually mean, "attach it, like a .txt file"? Bottom line, taking your question literally...you can't. You can insert contents, or some link to it.

Gerry
 

I think we're talking semantics here.

From a User perspective there is very little difference between a file attached to an e-mail and an embedded object displayed as an icon in a Word file.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Semantics it may be. However, there is a huge difference. The first is is/was sent between people across the network, as two distinct entities. To keep the attachment, you have to explicitly SAVE IT, because it is DIFFERENT from the email.

An embedded file is IN the file, and is, unless deleted, a part of a single entity. An embedded file (shown as an icon) does not point back to another file. It is already there. A linked-back file DOES point back, and if the file it points to is on a distant local hard drive...tough luck, ain't it.

An email attachment is ALWAYS available to the person who opens the email - unless of course security admin has stripped it off - another isse.

OK, I have a bugbear.

Semantics has been denigrated for centuries, but the
original term is an understanding of "true meaning"...not just a fuzzy word game. "The study or science of meaning in language forms. " It is absolutely incorrect to use "semantics" to describe a situation where people think a word or phrase means different things. Semantics is like code really. That is why we explicitly name objects. It leaves no interpretation (which is what people normally think semantics is...interpretation). Sematics is like a Dim declaration...you explicitly state THIS is what it means. When someone uses a different interpretation, their compilier (ie. the persona, bias, personality, etc etc) is in fact often returning a run-time error.

A very good example is the word "Intelligence".. Most people have an association with speed. Someone who thinks quickly, is overt, and often clever and interesting.

Wrong. Inteleligence has nothing to do with speed orcleverness. Intelligence is the ability to aquire and apply knowledge. Intelligence is directly related to the ability to solve problems. Period. The speed of which is NOT a factor of intelligence. I have know a number of people who thought they were stupid because they were so slow at things. However, they invariably solved the problem they were faced with. THIS is intelligence, not the speed of the process. However, I have certainly got into many a...discussion regarding this.

I gotta stop posting here....

Not there is an off thread post...except...that sematic word was used.

Gerry
 
Hi Gerry,

Originally from sema (as in semaphore as well, I guess) [smarty]

Might as well go off-topic; we seem to have lost the OP [wink]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
To get back to the original post, you can unprotect the document and copy the last row of the table.

Code:
Dim r As Range
Set r = ActiveDocument.Tables(1).Rows(ActiveDocument.Tables(1).Rows.Count)
r.Copy
r.Paste
Set r = Nothing

This copies the LAST row (ActiveDocument.Tables(1).Rows.Count). if it is another row, you can replace the count with the specific row number.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top