Right now I have teardown reports that have a simple "insert picture" button to make things easier. It works great with all columns unhidden. However when I try to hide all outside columns to clean up the report a bit, it is throwing the picture sizes all off.
This is what I have now (working fine):
This is what happens when I hide the outside columns:
And here is the code I have:
So how can I alter the size so that it does not take the hidden columns into affect. I have to leave the aspect ratio locked because some pictures will be taken horizontally, and some will be taken vertically. So I can't just lock in a set width and height.
Any help is appreciated.
This is what I have now (working fine):
This is what happens when I hide the outside columns:
And here is the code I have:
Code:
Sub LoadMultipleImages()
Dim arrSelected() As String
Dim i As Long
Dim rngDest As Range
Dim objPic As Object
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg"
.InitialFileName = CurDir
.FilterIndex = 2
If .Show = -1 Then
For i = 1 To .SelectedItems.Count
ReDim Preserve arrSelected(1 To i)
arrSelected(i) = .SelectedItems(i)
Next
Else
Exit Sub
End If
End With
Set rngDest = Range("A65536").End(xlUp).Offset(4, 0)
For i = 1 To UBound(arrSelected)
Set objPic = ActiveSheet.Pictures.Insert(arrSelected(i))
With objPic
.ShapeRange.LockAspectRatio = msoTrue
.ShapeRange.Width = 215#
End With
objPic.Cut
ActiveSheet.PasteSpecial Format:="Picture (GIF)", Link:=False, DisplayAsIcon:=False
Selection.Left = rngDest.Left
Selection.Top = rngDest.Top
Set rngDest = rngDest.Offset(1 + (Selection.Height \ 15))
Next
End Sub
So how can I alter the size so that it does not take the hidden columns into affect. I have to leave the aspect ratio locked because some pictures will be taken horizontally, and some will be taken vertically. So I can't just lock in a set width and height.
Any help is appreciated.