#1
|
|||
|
|||
Remove hypertext from clipboard
I'm using a script that copies the content of a table in a Word document:
Code:
Selection.Tables(1).Range.Copy This problem would evaporate if I could strip away the hypertext from the selection, or from the clipboard after the text is copied. Any thoughts on how my macro might eliminate hypertext? Example: if xxx@yyy.zzz is a clickable link in the table, I want the text of the email address, but without it being a hypertext. I'd be good if the macro stripped away hypertext from the table before copying the table. But my preference would be for the change to happen in Variable-Land. |
#2
|
|||
|
|||
I think I found a solution:
Code:
Selection.Tables(1).Range.Fields.Unlink Selection.Tables(1).Range.Copy |
#3
|
|||
|
|||
That will work except:
|
#4
|
|||
|
|||
Hi Charles,
I would prefer to retain hypertext links in the table. Once the table is in the clipboard, that would be the perfect moment to eliminate hypertext. But if stripping hypertext from the clipboard is too complicated, I can live with my solution! |
#5
|
|||
|
|||
I would not attempt stripping it from the clipboard, but from the pasted text. If necessary, you could create a scratch document, paste it there, and clear it from the pasted text, then copy that and close the scratch document without saving, then you would have it in the clipboard.
Here is a macro that unlinks all hyperlinks in the first table of a document. Code:
Sub HyperlinkFieldUnlink() ' Charles Kenyon 2023-01-22 Dim oField As Field Dim oRange As range On Error Resume Next Set oRange = ActiveDocument.Tables(1).range For Each oField In oRange.Fields If oField.Type = wdFieldHyperlink Then oField.Unlink End If Next oField Set oField = Nothing On Error GoTo -1 Set oRange = Nothing End Sub |
#6
|
|||
|
|||
Hi Charles,
This works nicely, too. I was able to modify your code so the table, sans hypertext, is copied to the clipboard. Thank you! The reason I want to strip hypertext from the clipboard, rather than from the table, is that the text, after it's copied, doesn't get pasted. I assign whatever is in the clipboard to a text variable, and parse it. But I know nothing about the metadata associated with the hypertext, so I can't delete it. I was hoping there might be a way to unlink hypertext from the clipboard before I assign the clipboard to a variable. |
#7
|
|||
|
|||
Quote:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing hypertext to normal text | tcritchley07 | Word | 2 | 11-23-2019 09:52 AM |
Error with Clipboard - Getting Spaces Out of Clipboard | StephenRay | Word VBA | 14 | 09-27-2017 01:07 PM |
Hypertext links within document? (not to a website) | cosiyak | Word | 1 | 05-22-2011 01:26 PM |
Hypertext Question | Juc1 | Word | 6 | 05-05-2011 06:09 AM |
hypertext link to a specific page of a pdf file | serbring | OneNote | 6 | 03-04-2011 01:20 AM |