Go1rish
New Member
- Joined
- Mar 25, 2014
- Messages
- 5
Hello. I've created a macro that I love which allows me to replace an image on multiple sheets with the click of the button. I've been asked if I can add the file path for the image (which is saved on the network) to one of those sheets. The part of the macro that adds the image to the sheet in question is:
I now want to add that file path for the image into Cell F80 on the sheet "Admin Set-up Sheet". Any suggestions?
Thank you.
Rich (BB code):
Sub SwapPic()
ThisWorkbook.Worksheets("Costing Form")
Dim PicFileName As String
With Application.FileDialog(msoFileDialogFilePicker)
.Show
On Error Resume Next
PicFileName = .SelectedItems(1)
On Error GoTo 0
End With
If PicFileName = "" Then Exit Sub
With ActiveSheet.Shapes(Application.Caller)
.TopLeftCell.Select
.Delete
End With
With ActiveSheet.Pictures.Insert(PicFileName)
.Name = "UserPic"
.OnAction = "SwapPic"
End With
With ActiveSheet.Shapes.Range(Array("UserPic")).Select
If Selection.ShapeRange.Height < Selection.ShapeRange.Width Then
Selection.ShapeRange.Height = 150
Else: Selection.ShapeRange.Height = 150
End If
End With
'Delete Pic on Admin
With Sheets("Admin Set-up Sheet").Select
ThisWorkbook.Worksheets("Admin Set-up Sheet")
ActiveSheet.Shapes.Range(Array("UserPic")).Select
Selection.Delete
End With
'Copy to Costing Form Pic
With Sheets("Costing Form").Select
ActiveSheet.Shapes.Range(Array("UserPic")).Select
Selection.Copy
End With
'Paste to Admin Sheet and Adjust Height
With Sheets("Admin Set-up Sheet").Select
Range("A74:D83").Select
ActiveSheet.Paste
ActiveSheet.Shapes.Range(Array("UserPic")).Select
If Selection.ShapeRange.Height < Selection.ShapeRange.Width Then
Selection.ShapeRange.Width = 245
ThisWorkbook.Worksheets("Admin Set-up Sheet")
Else: Selection.ShapeRange.Width = 245
ThisWorkbook.Worksheets("Admin Set-up Sheet")
End If
End With
'back to Costing Form
With Sheets("Costing Form").Select
Range("I4:N4").Select
ThisWorkbook.Worksheets("Costing Form")
End With
Range("I4:N4").Select
End Sub
I now want to add that file path for the image into Cell F80 on the sheet "Admin Set-up Sheet". Any suggestions?
Thank you.
Last edited by a moderator: