PDA

View Full Version : how to open a file with Win Photo Viewer



levraininjan
06-05-2010, 01:27 PM
Hi there
I am new to programming in VBE, so please bear with me if it is an elementary question:

I have put a standard open file dialog in a program, and I want the program to open the selected file in windows photo viewer when the user clicks "open".

Can someone please help me with the command to open a picture with Windows Photo Viewer / Windows Picture and Fax Viewer, given the path + filename as a string?

If it makes it simpler, we may assume that Photo Viewer is the default program to open this type (.jpg) of file.

Thanks you for reading my post :mayi:

Pieka

mdmackillop
06-07-2010, 01:03 PM
Try this

Sub Test()
Dim FileToOpen
FileToOpen = Application _
.GetOpenFilename("Picture Files (*.jpg), *.jpg")
If FileToOpen <> False Then
ActiveWorkbook.FollowHyperlink FileToOpen
End If
End Sub

levraininjan
06-08-2010, 11:26 AM
Thanks Mdmackillop

I tried your code and it works, but there are two issues that I still need to overcome, but still don't know how:

a) it opens the pictures with my default web browser (IE) instead of Photo Viewer (I specifically want Photo Viewer)

b) it needs to an Excel App to run - I want to run it directly from a .NET vbexpress form. (I can do it using a hidden excel app, but would prefer to be a bit more elegant than that.)

Could you advise further?

Thanks for your help so far :bow:

Pieka