+ Reply to Thread
Results 1 to 6 of 6

Hyperlink onclick override possible?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2023
    Location
    dublin, ireland
    MS-Off Ver
    2019
    Posts
    26

    Hyperlink onclick override possible?

    Hi,

    I have been looking on google all day without any luck. IS there such a VBA script that could be written in Outlook as one that can take a link in an email and re-direct it?

    we have emails coming in with dodgy links....i would love to have a script that onClick behavior is triggered and something other than open Edge and display the webpage happens.

    for example i would love a script that when a user clicks a link a popup comes up and says not allowed - or am i asking for the impossible

    Im guessing this is extremely tricky.

    Thanks

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,970

    Re: Hyperlink onclick override possible?

    I have been researching this and the answer I keep finding is that there is no event that is triggered when a user clicks a link in an Outlook email, so VBA cannot detect it. That doesn't prove that it's impossible but I wouldn't hold my breath.

    Also your strategy seems extreme--no links are allowed at all? I think a better solution to this might be good protection on the web browser, like MalwareBytes.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    06-14-2023
    Location
    dublin, ireland
    MS-Off Ver
    2019
    Posts
    26

    Re: Hyperlink onclick override possible?

    yes extreme but we have emails getting through our filtering service and very dangerous ones - so i wanted to take drastic action.

  4. #4
    Registered User
    Join Date
    06-14-2023
    Location
    dublin, ireland
    MS-Off Ver
    2019
    Posts
    26

    Re: Hyperlink onclick override possible?

    i came across this code on google:

    Sub RemoveAllHyperlinksinanEmail()
        Dim objMail As Outlook.MailItem
        Dim objInspector As Outlook.Inspector
        Dim objDocument As Word.Document
        Dim objHyperlinks As Word.Hyperlinks
        Dim objHyperlink As Word.Hyperlink
        Dim strPrompt As String
        Dim nResponse As Integer
    
        Set objMail = Application.ActiveInspector.CurrentItem
     
        Set objInspector = objMail.GetInspector
        Set objDocument = objInspector.WordEditor
        Set objHyperlinks = objDocument.Hyperlinks
     
        On Error Resume Next
     
        If objHyperlinks.Count > 0 Then
           strPrompt = "Are you sure to remove all the hyperlinks in this email?"
           nResponse = MsgBox(strPrompt, vbYesNo + vbQuestion, "Remove All Hyperlinks")
           If nResponse = vbYes Then
              While objHyperlinks.Count > 0
                    objHyperlinks(1).Delete
              Wend
              objMail.Save
          End If
        End If
    End Sub
    i get compile error: user-defined type not defined for this line:
     Dim objDocument As Word.Document
    any ideas?
    Last edited by gussy81; 07-20-2023 at 06:12 AM.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,970

    Re: Hyperlink onclick override possible?

    If you have types from the Word library you have to set a reference to Word. In the VBA editor go to Tools > References and check the box for Microsoft Word.

    Word ref.jpg

  6. #6
    Registered User
    Join Date
    06-14-2023
    Location
    dublin, ireland
    MS-Off Ver
    2019
    Posts
    26

    Re: Hyperlink onclick override possible?

    ok great i did that......but then the error re-appears for:
    Set objHyperlinks = objDocument.Hyperlinks
    do i need to select a reference for this also? the debugger highlights .hyperlinks and says: method or data member not found

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. onclick help
    By robfledderus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2022, 01:13 PM
  2. getting the onClick of retrieved hyperlink
    By mochano in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-25-2009, 06:53 AM
  3. OnClick Sub Deletion from VBE
    By cgi_pro in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-26-2006, 07:48 AM
  4. onClick functionality?
    By Clauddvon in forum Excel General
    Replies: 2
    Last Post: 10-29-2006, 01:15 AM
  5. [SOLVED] CommandBarButton onClick
    By virgin69@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2006, 10:25 AM
  6. [SOLVED] dynamic hyperlink or onclick event
    By Tasha in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-16-2005, 10:42 AM
  7. onClick in Excel
    By Nicole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1