Emulate RightClick in an Excel Macro

What I am trying to do

Write a Macro in an Excel Workbook which will enable me to:

1.         Go to a web site from a hyperlink within an Excel Worksheet.

2.         Identify and copy a required hyperlink which is within that web site.

3.         Return to the Excel Worksheet.

4.         Paste the displayed text of the copied hyperlink as text to display in the cell containing the hyperlink which led to the web site.

5.         Move down one cell to the next hyperlink in the Excel Worksheet.

Then repeat steps 1 to 5 above (Say 2500 times using a simple loop).

Manual Keystroke Sequence

Left Click on the Hyperlink.

Highlight and copy the link required in the web site visited.

Return to the Excel Workbook.

Right Click on the active cell.

Select Edit HyperLink.

Select Text To Display.

Paste New Text To Display from ClipBoard.

Enter.

Delete Underlining.

Bold.

Move down one cell.

Macro to do the Manual Keystroke Sequence

Emulate RightClick in an Excel Macro

    ActiveCell.Select

    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

   

    newHour = Hour(Now())

    newMinute = Minute(Now())

    newSecond = Second(Now()) + 15

    waitTime = TimeSerial(newHour, newMinute, newSecond)

    Application.Wait waitTime

   

    Emulate RightClick on the ActiveCell on this Line

    SendKeys "%H"

    SendKeys "%T"

    SendKeys "^V"

    SendKeys "ENTER"

   

    Selection.Font.Underline = xlUnderlineStyleNone

    Selection.Font.Bold = True

    ActiveCell.Offset(1, 0).Select

1,308 views 0 replies