+ Reply to Thread
Results 1 to 7 of 7

How to use a macro to open a jpg in it's default application

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    3

    How to use a macro to open a jpg in it's default application

    Hi all,

    I have a workbook that is being used to create codes for a large library of sketches.
    The sketches are all saved as jpgs on a hard drive.
    Each row refers to a different code (& sketch). The full path for the sketch is found in column H.
    I previously tried using the Hyperlink function to automatically create a hyperlink to the sketch in column I. This worked well, except that there will be thousands of codes in the workbook and having a permanent hyperlink for each row makes excel run far too slowly.

    I wanted to create a command button called 'get sketch' at the top of the worksheet. The idea was that the user would select the cell with the relevant path and click the command button which would open the sketch in Preview.
    I can't find any code to make this work.

    PS: This is my first post so apologies if I do something wrong

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to use a macro to open a jpg in it's default application

    The HYPERLINK() function is a text function, 1000s of these formulas will not affect the performance of your workbook in any way.
    If there were an address to a jpg file listed in A1, in B1 this formula would provide a clickable link:

    =HYPERLINK(A1, "Open")


    You're sure you're not referring to actual CTRL-K hyperlinks installed INTO the cells? That could.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to use a macro to open a jpg in it's default application

    When you joined the forum recently you agreed to abide by the Forum Rules, but in haste I fear you might not have actually read them. Please stop and take a moment to read them now. We all follow these rules for the benefit of all, as must you. Thanks.

    (link above in the menu bar)
    ===================================

    (for instance, you just posted a VBA question in a general forum, though in the end I don't think you'll need VBA.)

  4. #4
    Registered User
    Join Date
    04-29-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    3

    Re: How to use a macro to open a jpg in it's default application

    Hi JBeaucaire,

    Thanks for your quick response. This is the function I tried before, with the address in column H and the hyperlink function in column I.
    I tried saving the workbook with & without the hyperlinks. The workbook with the hyperlinks took a few minutes just to open, but the one without opened almost instantly.
    Any thoughts?
    Apologies for posting in the wrong place but I was guessing that something like ShellExecute was what I was looking for?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to use a macro to open a jpg in it's default application

    My belief is there is something else going on, then. HYPERLINK() formulas are text formulas, they are not active and have no affect unless you click one, then Excel figures out what to do at that moment.

    Zip up you example file and let's take a look.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  6. #6
    Registered User
    Join Date
    04-29-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    3

    Re: How to use a macro to open a jpg in it's default application

    Ok I've uploaded a small version of the workbook I've made.
    If you click on the cat it will prompt you to create a new code.
    I haven't included the Hyperlink formula in column I.

    Thanks : )
    Attached Files Attached Files

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to use a macro to open a jpg in it's default application

    I wanted to see your troublesome large workbook with formulas... that's why I suggested zipping it up so it would load into the forum.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1