VBA Excel open file per click

Grz3siu

New Member
Joined
Apr 21, 2015
Messages
7
Hello, I need to open the file via VBA. After clicking on the red label, I want the file to open. I want to enter the file paths directly in the VBA code. Do you have any suggestions?

open-file.png
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I cannot see your image clearly (but I think the label caption contains the name of a TIF file)
and you have not said what is supposed to happen after "I want the file to open" (is the image supposed to go somewhere?? etc)

Perhaps...
VBA should allow user to
- view an image file
- after clicking on a label on a userform
- where the label's caption is the image file name

If so, try this
- assumes all images are in the same folder
- caption contains the file name including extension

Code goes in userform module
Code:
Private Sub [I]LabelName[/I]_Click()
    Const Fpath = "C:\Folder\subFolder[COLOR=#ff0000]\[/COLOR]"                        [I]'end string with [COLOR=#ff0000]path separator[/COLOR][/I]
    Dim fName As String
    fName = [I]LabelName[/I].Caption
    Shell ("RunDLL32.exe C:\Windows\System32\Shimgvw.dll,ImageView_Fullscreen " & Fpath & fName)
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top