In excel vba coding, I have found a run-time error '481': Invalid Picture.

sunilhaokha

New Member
Joined
Aug 10, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Well, I was trying to load picture in an Image Control with a button click through a Dialog Box for selection of the image file that i wanted to. Here is the codes.

Private Sub CommandButton1_Click()

Dim filePath As String
Dim fileInt As Integer

Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
fileInt = Application.FileDialog(msoFileDialogOpen).Show

If fileInt <> 0 Then
filePath = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
Me.Image1.Picture = LoadPicture(filePath) ' I found the error type here
Me.Image1.PictureSizeMode = fmPictureSizeModeStretch
End If

End Sub


And also, please help me to pass the selected image file into a Cell Range with Auto-Adjustment according to the range.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Well, I was trying to load picture in an Image Control with a button click through a Dialog Box for selection of the image file that i wanted to. Here is the codes.

Private Sub CommandButton1_Click()

Dim filePath As String
Dim fileInt As Integer

Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
fileInt = Application.FileDialog(msoFileDialogOpen).Show

If fileInt <> 0 Then
filePath = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
Me.Image1.Picture = LoadPicture(filePath) ' I found the error type here
Me.Image1.PictureSizeMode = fmPictureSizeModeStretch
End If

End Sub


And also, please help me to pass the selected image file into a Cell Range with Auto-Adjustment according to the range.
The code is accepting only with the *.jpg extension but other type of image file extensions are not working. So, the error type is occurring. Please help
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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