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 / June 2005

Tip: Looking for answers? Try searching our database.

macro to copy text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
akiwi - 26 Jun 2005 23:35 GMT
Hi

Is it possible to create a macro to do this?

I have a table with the left hand column containing sequential numbers
say 1 to 100 (i.e. 100 rows).  The next column has a name associated
with that number.  There is a later section in the document associated
with each of those names and in that section there is a table
containing the same name (or shortened version of it) and the
associated number.

At some stage, the numbers in the main table may change  e.g. if a
line is added or deleted at row 50 then the numbers following go up or
down by one   - the number in each of the individual sections also
then has to go up or down by one so that it is the same as the number
associated with the name back in the main table.  Updating the numbers
in the main table is fairly easy (I think), but having updated them
(e.g. by copying from somewhere) I need to run a macro on each row of
the table to update the "remote" numbers.

I can create a bookmark back in the main table to link to the number
in the later part of the document but to get to the destination of the
bookmark you have to do CTRL Click in the main table  - which doesn't
work during macro recording.

I would prefer not to use "linked text" and paste special because the
link seems to get lost fairly easily e.g. if you overwrite it with a
new number, say by regenerating the entire column of numbers by
copying in from Excel.

Thanks for any suggestions.

Graeme
Helmut Weber - 27 Jun 2005 13:59 GMT
Hi,

a matter of logic rather than programming.
As I am no good at fields and related topics
of document automation, I'd try it this way.

Case 1
Insert one or more empty rows in table x.
Insert the text you like.
Leave the cell for the numbering empty.
Check wich cells in column 1 are empty
Get e.g. Selection.Information(wdEndOfRangeRowNumber)
You know then, where a row was inserted
e.g. rows 7 9 and 12 are new rows
Insert new rows in table y after line 6,
after line, 8 and after line 11.
Transfer the text
Renumber both tables (column 1).

Case 2:
One or more rows deleted:
Then there are numbers missing.
If the numbering starts with 3,
then rows 1 and 2 where deleted
If there are breaks in numbering,
then the "gap" rows where deleted.
If there are no gaps, but the number of rows
in table x is smaller then in table y, then
there were rows deleted from the end of
table x ...
Delete then rows with the numbers so achieved
in table y...

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
Graeme Prentice - 28 Jun 2005 10:02 GMT
I think I didn't explain what I needed very well, but thanks for taking
the trouble to reply.

Graeme

> Hi,
>
[quoted text clipped - 33 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000
 
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.