KlausW
Active Member
- Joined
- Sep 9, 2020
- Messages
- 458
- Office Version
- 2016
- Platform
- Windows
Hi
Anyone who can help modify this Useform, VBA code?
What I would like it to do is to start by inserting images in cell A1 and below.
And retrieve them from cell I3 in sheets (Stamdata)
Any help will be appreciated
Best regards
Klaus W
Anyone who can help modify this Useform, VBA code?
What I would like it to do is to start by inserting images in cell A1 and below.
And retrieve them from cell I3 in sheets (Stamdata)
Any help will be appreciated
Best regards
Klaus W
VBA Code:
Option Explicit
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Const cBorder = 2
Dim vArray As Variant, vPicture As Variant, pic As Shape, rng As Range
If Me.RefEdit1 = "" Then
Me.RefEdit1.SetFocus
MsgBox "Please select a cell, then try again.", vbExclamation
Exit Sub
End If
vArray = Application.GetOpenFilename(FileFilter:="Pictures (*.png; *.jpg; *.jpeg; *.tif), *.png; *.jpg; *.jpeg; *.tif", _
Title:="Select Picture to Import", MultiSelect:=True)
If Not IsArray(vArray) Then
MsgBox "You didn't select any pictures. Please try again.", vbExclamation
Exit Sub
End If
Set rng = Range(Me.RefEdit1).MergeArea
For Each vPicture In vArray
Set pic = ActiveSheet.Shapes.AddPicture(Filename:=vPicture, LinkToFile:=False, SaveWithDocument:=True, _
Left:=rng.Left + cBorder, Top:=rng.Top + cBorder, Width:=-1, Height:=-1)
With pic
.LockAspectRatio = False
.Width = rng.Width - 2 * cBorder
.Height = rng.Height - 2 * cBorder
.Placement = xlMoveAndSize
End With
If Me.OptionButton1 Then
Set rng = rng.Offset(1, 0)
Else
Set rng = rng.Offset(0, 1)
End If
Next vPicture
Set pic = Nothing
Unload Me
End Sub
Private Sub UserForm_Click()
End Sub