Link file to basic shape and change colour

Hannes 20 Reputation points
2026-08-03T07:51:10.72+00:00

Good morning. I want to insert a basic shape in a cell in excel. Once a file is linked to the shape, the basic shape must change colour from red to green. Please assist with the VBA to do the colour change once the file is linked.

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

Answer accepted by question author

Liora 165 Reputation points Independent Advisor
2026-08-03T09:15:30.09+00:00

Dear Hannes,

I hope you’re having a good day.

Based on my testing, a Shape in Excel retains its existing fill colour after a hyperlink is manually assigned. In other words, adding a hyperlink to a Shape does not automatically change the Shape formatting. Excel exposes the Shape's Hyperlink object through VBA, but there is no built-in VBA event that fires specifically when a hyperlink is added to a Shape.

If your goal is to use the Shape colour as a status indicator (for example, Red = no file linked, Green = file linked), one approach is to run a VBA procedure that checks whether the Shape contains a hyperlink and then updates its colour accordingly. The Shape.Hyperlink property can be used for this purpose.

Example:

Sub UpdateShapeColor()
Dim shp As Shape
Set shp = ActiveSheet.Shapes("
On Error Resume Next
If shp.Hyperlink.Address <> "" Then
shp.Fill.ForeColor.RGB = RGB(0, 176, 80) ' Green
Else
shp.Fill.ForeColor.RGB = RGB(255, 0, 0) ' Red
End If
On Error GoTo 0
End Sub

I hope this information helps point you in the right direction. If you run into any issues while trying the steps, or if something still doesn’t feel quite right, please don’t hesitate to reach out again. I’ll do my best to support you however I can.  

Looking forward to hearing back from you with any updates or additional details. 

Warm regards, 


If the answer is helpful, please select "Yes" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

Note: Please follow the steps in the forum documentation to enable email notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.