#1
|
|||
|
|||
paste from clipboard to selected paragraphs
Hi.
1. Is there a wildcard command to paste from the clipboard for the beginning of each selected paragraphs (only for the paragraphs I selected). 2. And another command, paste to the end of each selected paragraph/ thanks. |
#2
|
|||
|
|||
Hi, yacov! If I understand your task correctly, try the following.
Pasting at paragraphs' starts Technique 1 (manual, I'm sure you know it): select & copy what you want using Ctrl+A, then place the cursor at the start of each paragraph & press Ctrl+V; Technique 2 (using a macro): select & copy what you want using Ctrl+A, then select the paragraphs to paste to & run the following macro: Code:
Sub Paras_Paste_Start() Dim Rng As range Dim oPar As Paragraph Application.ScreenUpdating = False Set Rng = selection.range For Each oPar In Rng.Paragraphs oPar.range.InsertBefore vbCr & Chr(32) oPar.range.Previous.Paste Next oPar Application.ScreenUpdating = False Set Rng = Nothing End Sub Code:
Sub Paras_Paste_End() Dim Rng As range Dim oPar As Paragraph Application.ScreenUpdating = False Set Rng = selection.range For Each oPar In Rng.Paragraphs oPar.range.Characters.Last.InsertBefore Chr(32) oPar.range.Characters.Last.Previous.Paste Next oPar Application.ScreenUpdating = False Set Rng = Nothing End Sub |
#3
|
|||
|
|||
Thank you very much Vivka.
The second macro (for the end of the paragraph) works fine. The first macro gives me an extra paragraph. Instead of the pasting being in the selected paragraph, it actually creates another paragraph. but i can fix it by hand. so if it is hard to fix the macro i will manage like that. thanks again. |
#4
|
|||
|
|||
It's strange, because with me the 1st macro works properly. Anyway, try this one:
Code:
Sub Paras_Paste_Start() Dim Rng As range Dim oPar As Paragraph Application.ScreenUpdating = False Set Rng = selection.range For Each oPar In Rng.Paragraphs oPar.range.InsertBefore Chr(32) & Chr(32) oPar.range.Characters.First.Paste Next oPar Application.ScreenUpdating = False Set Rng = Nothing End Sub Last edited by vivka; 02-04-2024 at 01:42 PM. |
#5
|
|||
|
|||
works good thanks a lot.
i use Ditto clipboard manager and when i turn it off there is no extra paragraph with the macro. Sorry I didn't know that at first. |
#6
|
|||
|
|||
You are welcome, Yacov!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Replicate the copy/paste function, without involving the clipboard | alex100 | Word VBA | 8 | 11-09-2020 08:19 AM |
Macro for copying in clipboard more than one selected text | ghostwhisperer86 | Outlook | 0 | 03-31-2019 07:47 AM |
How to extract selected hyperlink address to clipboard? | poetofpiano | Word VBA | 8 | 02-18-2018 07:17 PM |
How to paste as a single para from clipboard having multiple paragraph | PRA007 | Word VBA | 8 | 12-04-2015 04:48 AM |
Find & selected paras with highlighted text & copy to clipboard | marceepoo | Word VBA | 1 | 09-14-2012 08:20 PM |