How to create a simple insert pic macro in Excel 2003

M

Melody

Hi,

I need to be able to insert a picture into a protected worksheet in a
particular cell and then resize it. Let me emphasize, I want to keep it
simple. Below is what I have so far and everything works except I want the
user to be able to browse and pick their own picture. What do I put in place
of the code for picking a particular picture to browse and pick any picture?

ActiveSheet.Unprotect
Range("A1:B2").Select

'What do I replace this code with?
ActiveSheet.Pictures.Insert( _
"C:\Documents and
Settings\casem02.AMER\Desktop\32604galloapproval.jpg").Select

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 712#
Selection.ShapeRange.Width = 892#
Selection.ShapeRange.Rotation = 0#
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowInsertingRows:=True
End Sub
 
D

Dave Peterson

Maybe this will help:

Option Explicit
Sub testme()

Dim myPictName As Variant
Dim myPict As Picture
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

myPictName _
= Application.GetOpenFilename("Picture files, *.bmp;*.jpg;*.gif")
If myPictName = False Then
MsgBox "try later!"
Exit Sub
End If

With wks
With .Range("a1:B9")
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Top = .Top
myPict.Left = .Left
myPict.Width = .Width
myPict.Height = .Height
End With
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top