Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default How to create a simple insert pic macro in Excel 2003

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.j pg").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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to create a simple insert pic macro in Excel 2003

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

Melody wrote:

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.j pg").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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Excel 2003 macro not working in Excel 2007 Bryan Excel Programming 0 June 19th 08 02:33 PM
How do I create a macro to insert an audio file into Excel? Mike Greene Excel Programming 2 December 12th 05 04:04 PM
Simple Macro, works in Excel 2002, 2003 but won't work in 2000 DJA[_2_] Excel Programming 5 September 28th 05 05:10 PM
Excel 2003, Insert Function, create full name & descriptions cybersurfer Excel Worksheet Functions 0 July 14th 05 05:13 PM
Help please on a simple macro to insert rows Michelle Curtin Excel Programming 1 October 3rd 03 05:20 PM


All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"