Hello to everyone,
Using my basic VBA knowledge I've been trying to code a image control that I embedded on a worksheet ("Picture Template"). I can find codes that will launch a image specific file browser but then I'm having a hard time making the link to actually show the image in the control that I created on the worksheet.
This is a code that I had found on another forum that I have been trying to manipulate. I can filter out the sheet protection stuff and at the end where it brings up the msg box to enter a cell for the image to be pasted in that's where I want to load it into my control (Image1).
Dim Pict
Dim ImgFileFormat As String
Dim PictCell As Range
Dim Ans As Integer
ActiveSheet.Protect True, True, True, True, True
ImgFileFormat = "Image Files (*.bmp),others, tif (*.tif),*.tif, jpg (*.jpg),*.jpg"
GetPict:
Pict = Application.GetOpenFilename(ImgFileFormat)
'Note you can load in any nearly file format
If Pict = False Then End
Ans = MsgBox("Open : " & Pict, vbYesNo, "Insert Picture")
If Ans = vbNo Then GoTo GetPict 'Now paste to userselected cell
GetCell:
Set PictCell = Application.InputBox("Select the cell to insert into", Type:=8)
If PictCell.Count > 1 Then MsgBox "Select ONE cell only": GoTo GetCell
PictCell.Select
ActiveSheet.Pictures.Insert(Pict).Select
The second thing I need to do is have the image displayed on another worksheet ("Template"). I know how to do this with other types of data but what I'm trying doesn't seem to be working for these controls.
Dim ws As Worksheet
Set ws = Worksheets("Picture Template")
Me.Image1.Picture = ws.Image1.Picture
Thank you for taking the time to help me out
Using my basic VBA knowledge I've been trying to code a image control that I embedded on a worksheet ("Picture Template"). I can find codes that will launch a image specific file browser but then I'm having a hard time making the link to actually show the image in the control that I created on the worksheet.
This is a code that I had found on another forum that I have been trying to manipulate. I can filter out the sheet protection stuff and at the end where it brings up the msg box to enter a cell for the image to be pasted in that's where I want to load it into my control (Image1).
Dim Pict
Dim ImgFileFormat As String
Dim PictCell As Range
Dim Ans As Integer
ActiveSheet.Protect True, True, True, True, True
ImgFileFormat = "Image Files (*.bmp),others, tif (*.tif),*.tif, jpg (*.jpg),*.jpg"
GetPict:
Pict = Application.GetOpenFilename(ImgFileFormat)
'Note you can load in any nearly file format
If Pict = False Then End
Ans = MsgBox("Open : " & Pict, vbYesNo, "Insert Picture")
If Ans = vbNo Then GoTo GetPict 'Now paste to userselected cell
GetCell:
Set PictCell = Application.InputBox("Select the cell to insert into", Type:=8)
If PictCell.Count > 1 Then MsgBox "Select ONE cell only": GoTo GetCell
PictCell.Select
ActiveSheet.Pictures.Insert(Pict).Select
The second thing I need to do is have the image displayed on another worksheet ("Template"). I know how to do this with other types of data but what I'm trying doesn't seem to be working for these controls.
Dim ws As Worksheet
Set ws = Worksheets("Picture Template")
Me.Image1.Picture = ws.Image1.Picture
Thank you for taking the time to help me out