Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code to work with ONLY active Sheet not all ?
The below code inserts a Photo into the selected cell and sizes it to suit
my needs, But i need this code to ONLY place a photo into the active sheet instead of ALL sheets in the workbook. How can i modify the below to do this?? ################################################## ##################### Sub Picture_Adder() Application.ScreenUpdating = False Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim myPic As Picture Dim res As Variant 'Const sAddress As String = ActiveCell Set WB = ActiveWorkbook res = Application.GetOpenFilename _ ("Image Files (*.jpg), *.jpg") If res = False Then Exit Sub For Each SH In WB.Worksheets ' <======================= ONLY ACTIVE WORK SHEET NOT ALL WORKSHEETS Set rng = ActiveCell 'SH.Range(sAddress) Set myPic = SH.Pictures.Insert(res) With myPic .Top = rng.Top .Left = rng.Left myPic.ShapeRange.LockAspectRatio = msoFalse myPic.ShapeRange.Height = 177# myPic.ShapeRange.Width = 235.5 myPic.ShapeRange.Rotation = 0# End With Next SH ' <======================================= DELETE THIS Application.ScreenUpdating = True End Sub ################################################## ############################## Regards Corey |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code to work with ONLY active Sheet not all ?
Sub Picture_Adder()
Application.ScreenUpdating = False Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim myPic As Picture Dim res As Variant 'Const sAddress As String = ActiveCell Set WB = ActiveWorkbook res = Application.GetOpenFilename _ ("Image Files (*.jpg), *.jpg") If res = False Then Exit Sub set SH = Activesheet Set rng = ActiveCell Set myPic = SH.Pictures.Insert(res) With myPic .Top = rng.Top .Left = rng.Left myPic.ShapeRange.LockAspectRatio = msoFalse myPic.ShapeRange.Height = 177# myPic.ShapeRange.Width = 235.5 myPic.ShapeRange.Rotation = 0# End With End if Application.ScreenUpdating = True End Sub -- Regards, Tom Ogilvy "Corey" wrote in message ... The below code inserts a Photo into the selected cell and sizes it to suit my needs, But i need this code to ONLY place a photo into the active sheet instead of ALL sheets in the workbook. How can i modify the below to do this?? ################################################## ##################### Sub Picture_Adder() Application.ScreenUpdating = False Dim WB As Workbook Dim SH As Worksheet Dim rng As Range Dim myPic As Picture Dim res As Variant 'Const sAddress As String = ActiveCell Set WB = ActiveWorkbook res = Application.GetOpenFilename _ ("Image Files (*.jpg), *.jpg") If res = False Then Exit Sub For Each SH In WB.Worksheets ' <======================= ONLY ACTIVE WORK SHEET NOT ALL WORKSHEETS Set rng = ActiveCell 'SH.Range(sAddress) Set myPic = SH.Pictures.Insert(res) With myPic .Top = rng.Top .Left = rng.Left myPic.ShapeRange.LockAspectRatio = msoFalse myPic.ShapeRange.Height = 177# myPic.ShapeRange.Width = 235.5 myPic.ShapeRange.Rotation = 0# End With Next SH ' <======================================= DELETE THIS Application.ScreenUpdating = True End Sub ################################################## ############################## Regards Corey |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code to work with ONLY active Sheet not all ?
Thanks Tom. :-) Regards Corey |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need VBA Code to Let User Define Active Sheet | Excel Discussion (Misc queries) | |||
How do i copy a active sheet to a new sheet with code and everything | Excel Programming | |||
Code to make a sheet active | Excel Programming | |||
Copy from active sheet and paste into new sheet using info from cell in active | Excel Programming | |||
Changing code that set's print area...to active sheet only | Excel Programming |