Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2023, 07:09 PM
Charles Kenyon Charles Kenyon is offline Remove hypertext from clipboard Windows 11 Remove hypertext from clipboard Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,584
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
Reply With Quote
  #2  
Old 01-22-2023, 08:25 PM
AlanCantor AlanCantor is offline Remove hypertext from clipboard Windows 10 Remove hypertext from clipboard Office 2019
Competent Performer
Remove hypertext from clipboard
 
Join Date: Nov 2020
Posts: 155
AlanCantor is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 01-23-2023, 11:09 AM
Charles Kenyon Charles Kenyon is offline Remove hypertext from clipboard Windows 11 Remove hypertext from clipboard Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,584
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by AlanCantor View Post
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.
There may well be a way. However, I do not know it and suggested a workaround.
  1. After copying, create a new blank document.
  2. Paste into that document.
  3. Run the macro to strip out the hyperlinks.
  4. Copy the modified text from the new document.
  5. Close the new document without saving.
At this point, the clipboard contains the text without the hyperlinks.
Reply With Quote
Reply



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
Remove hypertext from clipboard Hypertext links within document? (not to a website) cosiyak Word 1 05-22-2011 01:26 PM
Remove hypertext from clipboard Hypertext Question Juc1 Word 6 05-05-2011 06:09 AM
Remove hypertext from clipboard hypertext link to a specific page of a pdf file serbring OneNote 6 03-04-2011 01:20 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft