Adding an object - macro

Matty2470

New Member
Joined
Mar 7, 2002
Messages
24
Hi,

Can anyone help me? I want to have my users click a command button to open a dialogue to browse for a photo and add it to a field in a worksheet.

Please...:)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
On 2002-04-17 06:55, Matty2470 wrote:
Hi,

Can anyone help me? I want to have my users click a command button to open a dialogue to browse for a photo and add it to a field in a worksheet.

Please...:)

Try;

<pre/>
'This routine will prompt you for the file location
'Then ask you for the Top cell location to paste to.

Sub Insert_Pict()
Dim Pict
Dim ImgFileFormat As String
Dim PictCell As Range
Dim Ans As Integer

'ActiveSheet.Protect True, True, True, True, True
ImgFileFormat = "Image Files wmf (*.gif),*.gif,(*.bmp),others , jpg (*.jpg),*.jpg"

GetPict:
Pict = Application.GetOpenFilename(ImgFileFormat)
'Note you can load in nearly file format
If Pict = False Then End

Ans = MsgBox("Open : " & Pict, vbYesNo, "Insert Picture")
If Ans = vbNo Then GoTo GetPict

'Now paste to userselected cell
GetCell:
Set PictCell = Application.InputBox("Select the cell to insert into", Type:=8)
If PictCell.Count > 1 Then MsgBox "Select ONE cell only": GoTo GetCell

PictCell.Select
'PictCell.Activate
ActiveSheet.Pictures.Insert(Pict).Select


End Sub


'to delete ALL picture files then;

Sub DeletePicts()
Dim Pict As Object

For Each Pict In ActiveSheet.Shapes
MsgBox "This is " & Pict.Name & ": Type:= " & Pict.Type
If Pict.Type = 13 Then
Pict.Delete
End If
Next

End Sub




</pre>
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

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