![]() |
|
|
|
#1
|
||||
|
||||
|
If you recorded the copying, your macro would have a line like:
Selection.Copy
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Hi Paul,
Actually I am not recording the copying because the copied text comes from outside the Word program (info from web). So I should have worded that question slightly differently. Here is a video to show what I'm trying to do and the problem I am running into: https://youtu.be/Dx88UOHFsH8 How would I go about tweaking the vba to "paste from clipboard" both at the beginning of the macro (into the Word doc) and then at the end (to create a hyperlink address)? I am also posting the recorded vba below that I created when recording the video. Code:
Sub Macro133()
'
' Macro133 Macro
'
'
Selection.Paste
Selection.HomeKey Unit:=wdLine
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "https://doi.org/"
.Replacement.Text = "doi:"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.TypeText Text:="doi:"
Selection.MoveLeft Unit:=wdCharacter, Count:=4
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"https://doi.org/10.1177%2F1077800407301175", SubAddress:="", ScreenTip:= _
"", TextToDisplay:="doi:10.1177%2F1077800407301175"
End Sub
|
|
| Tags |
| copy and paste, macro, recorder |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro for copying text between two Words.
|
Demonic | Word VBA | 3 | 07-18-2017 09:08 PM |
Copying Certain Text From Numerous Cells using Macro
|
Sean_Needs_Help | Excel | 3 | 11-08-2016 04:39 PM |
| Macro recorder changing reference style for columns in pivot source | andylaw31 | Excel Programming | 0 | 06-15-2016 08:45 AM |
Macro recorder and ShowFieldCodes
|
Jennifer Murphy | Word VBA | 1 | 11-04-2012 01:55 AM |
Picture properties bug in Word 2010 Macro Recorder
|
ralphpickering | Word VBA | 5 | 10-24-2012 10:15 AM |