How can I change .jpg image background to transparent?

rruiz309

New Member
Joined
Apr 25, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi there!

I am trying to create a catalogue, considering that I have no experience on VB, so far I have managed very well with all the available resources in the internet, however I haven't been able to give a particular format to the image after I insert it.

Since my .jpg original image has a white background, I need it to be transparent so that the format of my catalogue won't be visually blocked by the background of the image.

I will much appreciate if someone can tell me which code shall I add and where?

My current code is as follows (sorry, some Spanish on it, hope the idea is clear)

----
Sub CrearCatalogo()

Dim RutaActual As String
Dim RangoImagen As Range
Dim shp As Object


On Error Resume Next

For Each shp In ActiveSheet.Shapes
shp.Delete

Next shp

RutaActual = ThisWorkbook.Path

ActiveSheet.Range("B2").Select

Do While ActiveCell.Offset(1, 0).Value <> Empty

Set RangoImagen = ActiveCell.Offset(1, 0)
ActiveSheet.Pictures.Insert (RutaActual & "\Images\" & RangoImagen.Value & ".jpg")
ActiveCell.Offset(0, 1).Select


Loop

On Error GoTo 0

End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi @rruiz309 , VBA/coding is not my cup of thee, but you can perhaps try this
VBA Code:
Sub test()

Dim shp As Shape
Dim ws As Worksheet

Set ws = ActiveSheet

For Each shp In ws.Shapes

    If shp.Type = msoPicture Then
         shp.PictureFormat.TransparencyColor = True
 
    End If

Next shp
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,170
Messages
6,123,422
Members
449,099
Latest member
COOT

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