Consulting

Results 1 to 9 of 9

Thread: click a button to open a picture

  1. #1

    click a button to open a picture

    Hi,

    I want to click a button in an Excel file to open a picture in a folder my company, eg ("C:\Users\XX\Desktop\FOLDER1\1.jpg")

    How can I do that?

    Thanks

  2. #2
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    the easiest way would be to use Shell to call a program passing the file name as a parameter... like:
    [VBA]Shell "mspaint.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"[/VBA]

  3. #3
    Quote Originally Posted by Sean.DiSanti
    the easiest way would be to use Shell to call a program passing the file name as a parameter... like:
    [vba]Shell "mspaint.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"[/vba]
    Thank you for your reply.
    Your code is work.

    However, i don't want to use mspaint to open the photo.

    I have tried to use "WLXPhotoGallery.exe"
    it is at C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery


    However, my code is not work

    Sub photo_Click()

    Shell "WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"

    End Sub



    Could you please tell me any mistake on my code?
    I think the problem is at WLXPhotoGallery.exe



    On the other hand, how can i insert a picture by checking a button?

    Thanks

  4. #4
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    use the full path:
    [VBA]Shell "C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery\WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"[/VBA]
    i didn't list the path in mine because mspaint is located in system32 and can be called without the path written out.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What do you mean by open? Are you trying to insert it into a spreadsheet?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    it looks like he wants to open it in another program, i think this one can be marked solved

  7. #7
    Quote Originally Posted by Sean.DiSanti
    use the full path:
    [vba]Shell "C:\Program Files\Windows Live\Photo Gallery\WLXPhotoGallery\WLXPhotoGallery.exe C:\Users\XX\Desktop\FOLDER1\1.jpg"[/vba] i didn't list the path in mine because mspaint is located in system32 and can be called without the path written out.
    hi Sean.DiSanti,
    Your code does work.
    However, the picture will be closed automatically just after it opens.



    it looks like he wants to open it in another program
    yes

  8. #8
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    closed automatically? it shouldn't be

  9. #9
    Quote Originally Posted by Sean.DiSanti
    closed automatically? it shouldn't be
    closed automatically? it shouldn't be
    yes closed automatically.

    Now, I use another way

    ActiveSheet.Pictures.Insert (" file' location + flie's name)

    This work.
    It inserts a picure instead of opening the picture by another program

    Thanks

Posting Permissions

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