ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro 2003 vs 2007 (https://www.excelbanter.com/excel-worksheet-functions/204283-macro-2003-vs-2007-a.html)

Ron

Macro 2003 vs 2007
 
This macros below allowed me to insert a picture that I choose into Cell G1
at the correct heigth and with in 2003. Now in 2007 it does not put it into
the cell I want so the placement on the Excel sheet is wrong and I have to
drag it to the desired cell. Any Ideas?

Sub InsertPicture()
Dim myPicture As String, MyObj As Object

Range("g1").Select

myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")

If myPicture = "False" Then Exit Sub

Set MyObj = ActiveSheet.Pictures.Insert(myPicture)

With MyObj
With .ShapeRange
.LockAspectRatio = msoFalse
.Height = 198
.Width = 280
End With
.Placement = x1MoveAndSize

End With

End Sub


joel

Macro 2003 vs 2007
 
Pictures don't go into cells but sits ontop of th eworksheet. You can make a
picture look as if it is in a cell but it is not really in the cell.try these
changes

Sub InsertPicture()
Dim myPicture As String, MyObj As Object


myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")

If myPicture = "False" Then Exit Sub

Set MyObj = ActiveSheet.Pictures.Insert(myPicture)

With MyObj
With .ShapeRange
.LockAspectRatio = msoFalse
.Left = Range("G1").Left
.Top = Range("G1").Top
.Height = Range("G1").Height
.Width = Range("G1").Width
End With
End With

End Sub


"Ron" wrote:

This macros below allowed me to insert a picture that I choose into Cell G1
at the correct heigth and with in 2003. Now in 2007 it does not put it into
the cell I want so the placement on the Excel sheet is wrong and I have to
drag it to the desired cell. Any Ideas?

Sub InsertPicture()
Dim myPicture As String, MyObj As Object

Range("g1").Select

myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", _
, "Select Picture to Import")

If myPicture = "False" Then Exit Sub

Set MyObj = ActiveSheet.Pictures.Insert(myPicture)

With MyObj
With .ShapeRange
.LockAspectRatio = msoFalse
.Height = 198
.Width = 280
End With
.Placement = x1MoveAndSize

End With

End Sub



All times are GMT +1. The time now is 08:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com