एमएस वर्ड VBA निकालने हाइपरलिंक से चयनित पाठ में शब्द

0

सवाल

मैं आभारी होंगे अगर किसी को मेरी मदद कर सकता है और क्या संकेत में परिवर्तित किया जाना चाहिए नीचे दिए गए कोड (पर मैं यह पाया www.extendoffice.com) प्रतिबंधित करने के लिए यह करने के लिए चयनित पाठ का हिस्सा नहीं है (काम करने के लिए पूरे दस्तावेज़).
कोड है निकालने हाइपरलिंक से एक शब्द डॉक्टर के लिए एक और.

Sub HyperlinksExtract()
    Dim oLink As Hyperlink
    Dim docCurrent As Document 'current document
    Dim docNew As Document 'new document
    Dim rngStory As StoryRanges
    Set docCurrent = ActiveDocument
    Set docNew = Documents.Add
    For Each oLink In docCurrent.Hyperlinks
        oLink.range.Copy
        docNew.Activate
        Selection.Paste
        Selection.TypeParagraph
    Next
     
    Set docNew = Nothing
    Set docCurrent = Nothing
End Sub
hyperlink ms-word selection vba
2021-10-29 14:38:25
1

सबसे अच्छा जवाब

0

चाल है स्टोर करने के लिए चयनित हाइपरलिंक में एक चर selectedHyperlinks.

इसके अलावा मैं हमेशा कोशिश से बचने के लिए कॉपी/पेस्ट.इसलिए मैं का उपयोग कर रहा हूँ Hyperlinks.Add विधि सम्मिलित करने के लिए, लिंक करने के लिए नया दस्तावेज़

Sub HyperlinksExtract()

    Dim docCurrent As Document
    Dim docNew As Document
    
    Set docNew = Documents.Add
    Dim rgTarget As Range: Set rgTarget = docNew.Range
    
    Dim selectedHyperlinks As Hyperlinks
    Set selectedHyperlinks = Selection.Hyperlinks   '<<< this is where the selected hyperlinks are stored in the variable
    
    Dim oLink As Hyperlink
    
    For Each oLink In selectedHyperlinks 
        rgTarget.Collapse wdCollapseEnd
        docNew.Hyperlinks.Add rgTarget, oLink.Address, oLink.SubAddress, , oLink.TextToDisplay
        rgTarget.Move wdParagraph, 1
        rgTarget.InsertParagraphAfter
    Next
     
End Sub

2021-11-04 18:41:52

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में