ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro to insert an object in a specific cell 2007` (https://www.excelbanter.com/excel-discussion-misc-queries/193893-macro-insert-object-specific-cell-2007%60.html)

mpsears62

Macro to insert an object in a specific cell 2007`
 
I am trying to insert an object in a specific cell. i can get it to work in
2003, but not in 2007 does anyone have any insight as to what i am doing
wrong....here is the code that i am using

Sub test()
'
' test Macro
' Macro recorded 7/7/2008 by mspears
'

'
Range("B30").select
ActiveSheet.Pictures.Insert("H:\scan0002.jpg").Sel ect
Selection.ShapeRange.PictureFormat.TransparentBack ground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyCol or = RGB(253, 253, 253)
Selection.ShapeRange.Fill.Visible = msoFalse
Application.CommandBars("Picture").Visible = False
End Sub

Dave Peterson

Macro to insert an object in a specific cell 2007`
 
From what I've read, xl2007 doesn't play nice with .select's with objects like
pictures.

Option Explicit
Sub test()
Dim myPict As Picture
With ActiveSheet
Set myPict = .Pictures.Insert("H:\scan0002.jpg")
End With

With myPict
.Top = .Parent.Range("B30").Top
.Left = .Parent.Range("b30").Left
.ShapeRange.PictureFormat.TransparentBackground = msoTrue
.ShapeRange.PictureFormat.TransparencyColor = RGB(253, 253, 253)
.ShapeRange.Fill.Visible = msoFalse
End With
End Sub

Should work in both xl2007 and earlier versions.

mpsears62 wrote:

I am trying to insert an object in a specific cell. i can get it to work in
2003, but not in 2007 does anyone have any insight as to what i am doing
wrong....here is the code that i am using

Sub test()
'
' test Macro
' Macro recorded 7/7/2008 by mspears
'

'
Range("B30").select
ActiveSheet.Pictures.Insert("H:\scan0002.jpg").Sel ect
Selection.ShapeRange.PictureFormat.TransparentBack ground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyCol or = RGB(253, 253, 253)
Selection.ShapeRange.Fill.Visible = msoFalse
Application.CommandBars("Picture").Visible = False
End Sub


--

Dave Peterson

mpsears62

Macro to insert an object in a specific cell 2007`
 
Thank you so very much.. i really appreciate the help...

"Dave Peterson" wrote:

From what I've read, xl2007 doesn't play nice with .select's with objects like
pictures.

Option Explicit
Sub test()
Dim myPict As Picture
With ActiveSheet
Set myPict = .Pictures.Insert("H:\scan0002.jpg")
End With

With myPict
.Top = .Parent.Range("B30").Top
.Left = .Parent.Range("b30").Left
.ShapeRange.PictureFormat.TransparentBackground = msoTrue
.ShapeRange.PictureFormat.TransparencyColor = RGB(253, 253, 253)
.ShapeRange.Fill.Visible = msoFalse
End With
End Sub

Should work in both xl2007 and earlier versions.

mpsears62 wrote:

I am trying to insert an object in a specific cell. i can get it to work in
2003, but not in 2007 does anyone have any insight as to what i am doing
wrong....here is the code that i am using

Sub test()
'
' test Macro
' Macro recorded 7/7/2008 by mspears
'

'
Range("B30").select
ActiveSheet.Pictures.Insert("H:\scan0002.jpg").Sel ect
Selection.ShapeRange.PictureFormat.TransparentBack ground = msoTrue
Selection.ShapeRange.PictureFormat.TransparencyCol or = RGB(253, 253, 253)
Selection.ShapeRange.Fill.Visible = msoFalse
Application.CommandBars("Picture").Visible = False
End Sub


--

Dave Peterson



All times are GMT +1. The time now is 11:39 PM.

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