Export Cell Range As JPEG and Save As

GCLIV91

New Member
Joined
Mar 6, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have a sheet in which I have 2 images within a cell to the left (A4) and a product code in the next cell (C4). I have to screenshot cell A4 and save the file as the product code in C4 (another program uses this data so they have to be saved in this format). I’m currently using the snipping tool but it’s taking a long time because there’s about 150 products a week within this sheet. Is there VBA that would save the contents of A4 as a JPEG with the file name of the contents of C4 within a specific folder?

Thank you in advance for any help!
 
I stand corrected.
After 115 cells being copied with a loop it started error messages.
So I replaced "Unload Me", that should not be there because the code was copied from a UserForm, with DoEvents and it worked fine.

Application.ScreenUpdating = False/True should be added.
Code:
Sub Save_Range_Or_Picture()
    Dim cv As String
    Dim myPath As String
    Dim sh As Worksheet
    Dim c As Range
    Set sh = ActiveSheet
    For Each c In sh.Range("A1:A" & sh.Cells(sh.Rows.Count, 1).End(xlUp).Row)
    Select Case Environ("computername")
        Case "DESKTOP"
            cv = "C:\Program Files\IrfanView\i_view64.exe"
        Case "LAPTOP"
            cv = "C:\Program Files (x86)\IrfanView\i_view32.exe"
    End Select
    myPath = "C:\Temp Folder\" & c.Offset(, 2).Value & ".jpg"

    c.Copy
    Shell cv & " ""/clippaste /convert=" & myPath & """", vbNormalFocus
DoEvents
Next c
End Sub

With thanks to snb and Hans V
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Code:
For Each c In sh.Range("A1:A" & sh.Cells(sh.Rows.Count, 1).End(xlUp).Row)
Above line should be moved to just before the "c.Copy" line
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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