tommyreebok
New Member
- Joined
- Mar 30, 2011
- Messages
- 3
Having upgraded to excel 2007 from 2003, my macro (below) no longer performs the function it was intended to do.
It is a simple macro that unlocks a spreadsheet then allows the user to insert an image, then it adjusts the cell height and width to match before protecting the sheet again.
any ideas?
Private Sub CommandButton10_Click()
Range("H1").Select
Sheets("Expense Claim").Unprotect Password:="control1"
Range("H1").Select
'Dim strFile As String
Application.ScreenUpdating = False
On Error Resume Next
'varible Picture1 is inserted down below - ***change both***
Picture1 = Application.GetOpenFilename("Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")
'edit "("Picture,*.*")" section to add or chanve visible file types
On Error Resume Next
ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234
Application.ScreenUpdating = True
Set Picture = Selection
'set cell height to picture size
Range("H1").Select
Picture.Top = Picture.TopLeftCell.Top
Picture.Left = Picture.TopLeftCell.Left
Picture.TopLeftCell.EntireRow.RowHeight = Picture.Height
Row = Row + 1
Range("H1").Select
Sheets("Expense Claim").Protect Password:="control1"
End Sub
It is a simple macro that unlocks a spreadsheet then allows the user to insert an image, then it adjusts the cell height and width to match before protecting the sheet again.
any ideas?
Private Sub CommandButton10_Click()
Range("H1").Select
Sheets("Expense Claim").Unprotect Password:="control1"
Range("H1").Select
'Dim strFile As String
Application.ScreenUpdating = False
On Error Resume Next
'varible Picture1 is inserted down below - ***change both***
Picture1 = Application.GetOpenFilename("Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")
'edit "("Picture,*.*")" section to add or chanve visible file types
On Error Resume Next
ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234
Application.ScreenUpdating = True
Set Picture = Selection
'set cell height to picture size
Range("H1").Select
Picture.Top = Picture.TopLeftCell.Top
Picture.Left = Picture.TopLeftCell.Left
Picture.TopLeftCell.EntireRow.RowHeight = Picture.Height
Row = Row + 1
Range("H1").Select
Sheets("Expense Claim").Protect Password:="control1"
End Sub