Changing Picture of Shapes("Image1") on Worksheet

zeaknam

New Member
Joined
May 17, 2016
Messages
2
Hi.. I have a problem.. why my image (ActiveX Image in workbooks("Logo.xls")) not changing..
VBA EXCEL 2007..
thank...


Private Sub LogoButton_Click()

Dim fs As FileDialog, myDir As String, wsLogo As Worksheet

Set fs = Application.FileDialog(msoFileDialogFilePicker)
fs.Title = "Select Your LOGO"

fs.Filters.Clear
fs.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1

myDir = ThisWorkbook.Path
Workbooks.Open myDir & "\Logo.xls"
Set wsLogo = Workbooks("Logo").Sheets("LOGO")

If fs.Show = -1 Then
a = fs.SelectedItems(1)
Me.Button.Picture = LoadPicture(a)
Sheet4.Image1.Picture = LoadPicture(a) 'This ActiveX image on Thisworkbook was changing...
wsLogo.Shapes("Image1").Fill.UserPicture a 'But this ActiveX image on Workbooks("Logo") not changing...
Workbooks("Logo").Close savechanges:=True
End If

End Sub



<!-- / message -->
<!-- controls -->
progress.gif
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi
Welcome to the board

This is a simple example that loads a picture into an image activeX object, using a shape reference.
Test first a simple example like this one and then adapt to your code.

Code:
Private Sub LogoButton_Click()
Dim ws As Worksheet
Dim img As Object
Dim sImgPathname As String

sImgPathname = "c:\tmp\a.jpg"
Set ws = Worksheets("Sheet1")

Set img = ws.Shapes("Image1").OLEFormat.Object.Object

img.Picture = LoadPicture(sImgPathname)

End Sub

Does this help?
 
Last edited:
Upvote 0
Private Sub LogoButton_Click()

Dim fs As FileDialog, myDir As String, wsLogo As Worksheet
Dim img as Object

Set fs = Application.FileDialog(msoFileDialogFilePicker)
fs.Title = "Select Your LOGO"

fs.Filters.Clear
fs.Filters.Add "Images", "*.gif; *.jpg; *.jpeg; *.bmp", 1

myDir = ThisWorkbook.Path
Workbooks.Open myDir & "\Logo.xls"
Set wsLogo = Workbooks("Logo").Sheets("LOGO")

If fs.Show = -1 Then
a = fs.SelectedItems(1)
Me.Button.Picture = LoadPicture(a)
Sheet4.Image1.Picture = LoadPicture(a)
set img = wsLogo.Shapes("Image1").OLEFormat.Object.Object
img.Picture = LoadPicture(a)
Workbooks("Logo").Close savechanges:=True
End If

End Sub



And it's DONE!!!..... Thankyou....
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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