caricamentoimmagini



  • caricamentoimmagini
    di silver (utente non iscritto) data: 26/08/2016 09:05:14

    ciao a tutti ho un problema con il codice seguente, il codice serve per inserire delle immagini in un file excel, il fatto è che queste immagini hanno nomi che non sono sempre dello stesso genere ovvero a volte sono il codice articolo a volte l'ean a volte parte della descrizione e proprio nel caso in cui sono parte della descrizione ottengo l'errore, quello che dovrebbe fare è se non ha trovato ne un file immagine con il codice articolo ne un file con il codice ean prendere i primi 13 caratteri della descrizione e cercare questa stringa all'interno dei nomi di files ma qui da " errore di runtime 13 tipo non corrispondente"

    e non capisco a cosa si riferisce ho provato a dimensionare tutte le variabili come stringa ma non va cmq

    grazie


     
    Sub InsImg()
    Application.ScreenUpdating = False
    ActiveSheet.Shapes.SelectAll
    Selection.Delete
    Dim Height As Single
    Dim Width As Single
    Dim Nfile As String
    Dim Nfile1 As String
    Dim Nfile2 As String
    Dim Nfile3 As String
    Dim Mfoto As String
    Dim Mfoto1 As String
    Dim Mfoto2 As String
    Dim Mfoto3 As String
    Dim mPath As String
    
    
    
    mPath = "E:immagini_web"
    
    R = 2 ''riga dalla quale iniziare  la ricerca
    LR = Range("A" & Rows.Count).End(xlUp).Row
    For I = R To LR
      Mfoto = ""
        Mfoto2 = ""
        Mfoto3 = ""
        Nfile = ""
        Nfile2 = ""
        Nfile3 = ""
        
        Mfoto = Replace(Cells(I, 1), "/", "_") '' INSERIRE IL NUMERO DELLA CELLA CHE CONTIENE IL CODICE
        Mfoto2 = Replace(Cells(I, 3), "/", "_") '' INSERIRE IL NUMERO DELLA CELLA CHE CONTIENE IL CODICE
        Mfoto3 = Left(Replace(Cells(I, 2), "/", "_"), 13) '' INSERIRE IL NUMERO DELLA CELLA CHE CONTIENE  DESCRIZIONE
        
        Nfile = Dir(mPath & "" & "*" & Mfoto & "*" & ".jpg")
        Nfile2 = Dir(mPath & "" & "*" & Mfoto2 & "*" & ".jpg")
        Nfile3 = Dir(mPath & "" & "*" & Mfoto3 & "*" & ".jpg")
        ''If Nfile = "" Then Nfile = Nfile2
        
        ''If Len(Mfoto) > 0 Then
            If Nfile = "" And Nfile2 = "" And Nfile3 = "" Then Mfoto = "mancante"
            If Nfile = "" And Nfile2 = "" And Nfile3 = "" Then Nfile = "mancante.jpg"
            If Nfile = "" And Nfile2 <> "" Then Nfile = Nfile2 And Mfoto = Mfoto2
            If Nfile = "" And Nfile2 = "" And Nfile3 <> "" Then Nfile = Nfile3 And Mfoto = Mfoto3
    
            
            If Dir(mPath & "" & Nfile) <> "" Then '
       
                  ''With ActiveSheet.Pictures.Insert(mPath & "" & mFoto & ".jpg")
                  '' SELEZIONARE LA CELLA DI DESTINAZIONE
                     With ActiveSheet.Shapes.AddPicture((mPath & "" & Nfile), False, True, 100, 50, -1, -1)
                     ''ActiveSheet.Pictures.Insert (mPath & "" & Nfile)
                    Height = .Height
                    
                    Width = .Width
                                    
                    .Top = Range("T" & I).Top
                    .Left = Range("T" & I).Left
                    .Height = Range("T" & I).Height
                    .Width = Width / (Height / Range("T" & I).Height)
                    
                    ''.Width = Range("O" & I).Width
                       Width = .Width
            ''For Each sh In ActiveWorkbook.Sheets
              If Nfile = "mancante.jpg" Then Cells(I, 1).Interior.ColorIndex = 36
            ''Next
    
                End With
            End If
        ''End If
    Next I
    Application.ScreenUpdating = True
    End Sub



  • di patel data: 26/08/2016 14:14:45

    allega il file