![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
Hello,
I'm trying to set up a Macro which will allow a button to be pressed to copy a selection of text from a report and copy it into a summary table. There will be 3 tables, which are Red, Amber, Green depending on the report issue raised, so the code needs to be able to select the right table, insert the row, and copy to the relevant text into that row. Is there a way this can be done, I have tried keywords as triggers, but I'm after a simple way to allow the text to be copy and pasted to the corresponding table. I am on a Mac, so making it extra hard in terms of VBA, Macro's and functions in Word! ![]() Thank you Lauren |
#2
|
|||
|
|||
![]()
I attach a stripped back example here of what I'm trying to achieve.
You can see the 3 summary tables at the top, where the written item is to be added as a new row. The written assessment is below. In the full report, there are more tables within the document providing different functions, but I'm not sure how to assign a table an ID as a reference to be able to target it with VBA to be able to add the rows, copy the text etc. Is there a way to highlight the selected text, and have a button to click to copy it to the red, orange or green table accordingly? Thanks in advance to anyone who can help advise. |
#3
|
||||
|
||||
![]()
If your H/M/L tables are always appearing in that order at the top of the document then your macros might work like this
Code:
Sub MoveIt_High() ILikeToMoveIt End Sub Sub MoveIt_Medium() ILikeToMoveIt 2 End Sub Sub MoveIt_Low() ILikeToMoveIt 3 End Sub Function ILikeToMoveIt(Optional iTbl As Integer = 1) Dim aRng As Range, aTbl As Table, aRow As Row Set aRng = Selection.Paragraphs(1).Range aRng.End = aRng.End - 1 Set aTbl = ActiveDocument.Tables(iTbl) Set aRow = aTbl.Rows.Add aRow.Cells(1).Range.FormattedText = aRng.FormattedText End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ashalles135 | Word VBA | 5 | 09-26-2018 09:49 AM |
![]() |
ArieH | Word VBA | 20 | 09-10-2017 04:23 PM |
![]() |
celiolopes | Word VBA | 2 | 08-25-2016 04:03 PM |
![]() |
caboy | Word VBA | 2 | 04-01-2015 07:00 AM |
Insert table in document - automatically updates second table in summary? | Mechanic | Word | 2 | 08-01-2012 09:44 PM |