Results 1 to 3 of 3

Thread: how to open a file with Win Photo Viewer

  1. #1

    how to open a file with Win Photo Viewer

    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


  2. #2
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    May 2004
    Try this
    Sub Test()
    Dim FileToOpen
    FileToOpen = Application _
    .GetOpenFilename("Picture Files (*.jpg), *.jpg")
    If FileToOpen <> False Then
    ActiveWorkbook.FollowHyperlink FileToOpen
    End If
    End Sub

    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.

    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3

    Re: how to open a file with Win Photo Viewer

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts