Roger
asked on
Automating addition of shortcut icons to excel worksheet cells
My excel worksheet contains a column of file addresses
I want to use AUTOMATION to add a graphic short cut to each row, so when I click a shortcut, it opens the file addressed on that row.
I did a manual trial, and recorded the macro below. It causes a shortcut (MyFilename.png) to be positioned within cell B7, and to gain a hyperlink which opens file: 'Support.log".
My MAIN QUESTION: This worksheet will end up as a large catalogue of files. I need to search for files against names or tags, and import and export file details; further - this list of utilities is likely to increase..
Given that requirement, is my intention of using shortcut icons the right way to go about building a directory of links to files? OR: are there better solutions?
My subsidiary QUESTION, is about computing .ScaleWidth and .ScaleHeight, please see below.
Thanks! Kelvin4
Sub Macro2()
Range("D7").Select
ActiveSheet.Pictures.Inser t("Path\My FileName.p ng").Selec t
Selection.ShapeRange.Scale Width 0.4923809159, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.Scale Height 0.4923809159, msoFalse, msoScaleFromTopLeft
ActiveSheet.Hyperlinks.Add Anchor:=Selection.ShapeRan ge.Item(1) , Address:= "Support.log"
End Sub
.ScaleWidth and .ScaleHeight needed to be changed to 0.7 for graphic MyFileName.png to fill the height of the Excel cell. Can VBA calculate the required values of .ScaleWidth and .ScaleHeight?
I locked the sheet:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
and Unlocked:
ActiveSheet.Unprotect
I want to use AUTOMATION to add a graphic short cut to each row, so when I click a shortcut, it opens the file addressed on that row.
I did a manual trial, and recorded the macro below. It causes a shortcut (MyFilename.png) to be positioned within cell B7, and to gain a hyperlink which opens file: 'Support.log".
My MAIN QUESTION: This worksheet will end up as a large catalogue of files. I need to search for files against names or tags, and import and export file details; further - this list of utilities is likely to increase..
Given that requirement, is my intention of using shortcut icons the right way to go about building a directory of links to files? OR: are there better solutions?
My subsidiary QUESTION, is about computing .ScaleWidth and .ScaleHeight, please see below.
Thanks! Kelvin4
Sub Macro2()
Range("D7").Select
ActiveSheet.Pictures.Inser
Selection.ShapeRange.Scale
Selection.ShapeRange.Scale
ActiveSheet.Hyperlinks.Add
End Sub
.ScaleWidth and .ScaleHeight needed to be changed to 0.7 for graphic MyFileName.png to fill the height of the Excel cell. Can VBA calculate the required values of .ScaleWidth and .ScaleHeight?
I locked the sheet:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
and Unlocked:
ActiveSheet.Unprotect
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Martin, am tied up presently, but should test the script tomorrow.
I get back promptly,
Kelvin.
I get back promptly,
Kelvin.
ASKER
Thank you for helping me so promptly.
I apologise for my late acknowledgement due to an unrelated issue.
Once I was able to test it, I got the code to work immediately, and the graphic looks great.
Kelvin
I apologise for my late acknowledgement due to an unrelated issue.
Once I was able to test it, I got the code to work immediately, and the graphic looks great.
Kelvin
You're welcome and I'm glad I was able to help.
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Open in new window