mellowdeep
New Member
- Joined
- Jan 2, 2015
- Messages
- 3
Hello there i have a excell addin thats importing pictures based on cell value.
The addin got 4 userforms
-selecting cell where the picture will be inserted.
-selecting the article value
-selecting the first and the last row
-selecting the folder where pictures are located.
The problem is that imported pictures are not saved with file so i want to save the pictures and send them by mail.
here is the addin code
I tryed changing the insert with
The problem here is that all the pictures are added not in the range cells but in the top left angle of the sheet.
How to set the pictures to be added where i want to?
regards
Anton
The addin got 4 userforms
-selecting cell where the picture will be inserted.
-selecting the article value
-selecting the first and the last row
-selecting the folder where pictures are located.
The problem is that imported pictures are not saved with file so i want to save the pictures and send them by mail.
here is the addin code
Code:
Sub ResimGetir()
UserForm1.Show (0)
End Sub
Sub ResimAyarla()
ResimSutun = Mid(Selection.Address, 2, 1)
If ResimSutun = "" Then End
ResimYukseklik = Selection.RowHeight
ResimGenislik = Selection.ColumnWidth
End Sub
Sub ResimAyarla2()
ArticleSutun = Mid(Selection.Address, 2, 1)
If ArticleSutun = "" Then End
End Sub
Sub ResimAyarla3()
ilkSatir = UserForm3.TextBox1
If ilkSatir = "0" Or ilkSatir = "" Then End
SonSatir = UserForm3.TextBox2
If SonSatir = "0" Or SonSatir = "" Then End
End Sub
Sub ResimAyarla4Default()
FolderName = ActiveWorkbook.Path & "\Images"
ResimAyarla5
End Sub
Sub ResimAyarla4Folderli()
FolderName = BrowseForFolder
ResimAyarla5
End Sub
Sub ResimAyarla5()
Range(ResimSutun & ilkSatir & ":" & ResimSutun & SonSatir).Select
Selection.RowHeight = ResimYukseklik
Range(ArticleSutun & ilkSatir).Select
Do
ilkAdr = Selection.Address
Adres1 = Right(ilkAdr, Len(ilkAdr) - 3)
On Error Resume Next
ImageName = Range(ArticleSutun & Adres1).Value
Select Case Len(ImageName)
Case 1
ImageName = "00000" & ImageName
Case 2
ImageName = "0000" & ImageName
Case 3
ImageName = "000" & ImageName
Case 4
ImageName = "00" & ImageName
Case 5
ImageName = "0" & ImageName
End Select
Range(ResimSutun & Adres1).Select
Application.ActiveSheet.Pictures.Insert(FolderName & "\" & ImageName & ".jpg").Select
If Selection.Width > Selection.Height Then Olcek = Selection.Width Else Olcek = Selection.Height
Selection.ShapeRange.IncrementLeft 3.75
Selection.ShapeRange.IncrementTop 2.25
Selection.ShapeRange.ScaleWidth (ResimYukseklik * 0.9 / Olcek), msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight (ResimYukseklik * 0.9 / Olcek), msoFalse, msoScaleFromTopLeft
Range(ResimSutun & Adres1 + 1).Select
Loop Until Adres1 = SonSatir
End If
End Sub
Function BrowseForFolder(Optional OpenAt As Variant) As Variant
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please select a Folder", 0, OpenAt)
On Error Resume Next
BrowseForFolder = ShellApp.self.Path
On Error GoTo 0
Set ShellApp = Nothing
Select Case Mid(BrowseForFolder, 2, 1)
Case Is = ":"
If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
Case Is = "\"
If Not Left(BrowseForFolder, 1) = "\" Then GoTo Invalid
Case Else
GoTo Invalid
End Select
Exit Function
Invalid:
BrowseForFolder = False
End Function
I tryed changing the insert with
Code:
ActiveSheet.Shapes.AddPicture(Filename:=FolderName & "\" & ImageName & ".jpg", _
linktofile:=fail, savewithdocument:=True, Left:=1, Top:=1, Width:=30, Height:=60).Select
The problem here is that all the pictures are added not in the range cells but in the top left angle of the sheet.
How to set the pictures to be added where i want to?
regards
Anton
Last edited: