Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

"Insert" button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Zed Rafi - 14 Feb 2005 20:16 GMT
Hello,

I'm currently building a template, in which I'd like to create a macro to
insert a block of formatted text automatically by clicking on a button.

Here's what i want to do :

'File No. X    Client name ABC

Contact name:            <TextField>
Contact phone number: <TextField>'    --> name and phone of the contact are
in a table.

I'd like to create a button which inserts an addiontal contact table
(contact name + field and contact phone no. + field), in case information
needs to be entered for more than 1 contact.

Any thoughts?
thanks a lot
Doug Robbins - 14 Feb 2005 23:29 GMT
It sounds like this is a data entry application, more than a template from
which multiple documents will be created?

Maybe the following code will be of use to you:

Sub addrow()

'

' Macro created 02/02/03 by Doug Robbins

' To add a new row to a table containing formfields in every column

' automatically on exit from the last cell in the present last row of the
table

Dim rownum As Integer, i As Integer

ActiveDocument.Unprotect

ActiveDocument.Tables(1).Rows.Add

rownum = ActiveDocument.Tables(1).Rows.Count

For i = 1 To ActiveDocument.Tables(1).Columns.Count

   ActiveDocument.FormFields.Add
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput

Next i

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
ActiveDocument.Tables(1).Columns.Count).Range.FormFields(1).ExitMacro =
"addrow"

ActiveDocument.Tables(1).Cell(ActiveDocument.Tables(1).Rows.Count,
1).Range.FormFields(1).Select

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub
Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Hello,
>
[quoted text clipped - 16 lines]
> Any thoughts?
> thanks a lot
Zed Rafi - 15 Feb 2005 14:52 GMT
> It sounds like this is a data entry application, more than a template from
> which multiple documents will be created?

no, not really, it's really a template i want to create.
what i want to do is create a printable form, which will be included in our
paper files. I want to create a contact sheet which comprises, by default, a
table with cells only for 1 contact person. If more than one contact needs
to be entered, i'd like to click on a button to create another array of
cells in the table, the first column of this new array of cells already
comrpising information like "Second contact name" and "Second contact
phone", and the facing cells of the array comprising blank text fields
enabling input therein. I'd like this sequence to be able to be repeated for
a third, fourth, etc... contact person.

there'a number of other information in the template.

i hope my question is more clear now.
thanks
Doug Robbins - 16 Feb 2005 00:01 GMT
The following code will add a row to the first table in the document and
insert Contact # Name in the first cell in that row.

With ActiveDocument.Tables(1)
   .Rows.Add
   .Cell(.Rows.Count, 1).Range.InsertBefore "Contact " & .Rows.Count & "
Name:"
End With

Changing # to second, third, fourth etc. can be done, but it's a bit more
work.

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>> It sounds like this is a data entry application, more than a template
>> from
[quoted text clipped - 18 lines]
> i hope my question is more clear now.
> thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.