Usuário com melhor resposta
Busca e Exibição de imagem

Pergunta
-
Saudações!
1- Tenho duas planilhas no Excell ( 1 e 2)
2- Na Planilha 1 tenho o Código do produto e o endereço de onde a imagems esta armazenada.
3- Na Planilha 2 (Planilha de Pesquisa) tenho uma celula onde digito o código do produto e ele me traz A1 = Preço do produto
A2 = quantidade em estoque, A13 endereço onde esta armazenado a imagem na planilha 1.
Se possível gostaria que fosse me passado a aplicação do VBA que pudesse me mostrar a imagem relacionada ao código digitado
Antecipadamente agradeço a disposição em ajudar e transmitir seu conhecimento!
Muito Obrigado!
Respostas
-
Tente isso:
Sub TestInsertPictureInRange() Dim objFSO As Object Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFolder As Object Dim objFile As Object Dim i As Integer i = 1 Set objFolder = objFSO.GetFolder("C:\Users\h162524\Desktop\") For Each objFile In objFolder.Files If InStrRev(objFile.Name, ".png") <> 0 Then InsertPictureInRange objFile.Path, Range("B" & i & ":C" & i) i = i + 1 End If Next objFile End Sub Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range) ' inserts a picture and resizes it to fit the TargetCells range Dim p As Object, t As Double, l As Double, w As Double, h As Double If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Dir(PictureFileName) = "" Then Exit Sub ' import picture Set p = ActiveSheet.Pictures.Insert(PictureFileName) ' determine positions With TargetCells t = .Top l = .Left w = .Offset(0, .Columns.Count).Left - .Left h = .Offset(.Rows.Count, 0).Top - .Top End With ' position picture With p .Top = t .Left = l .Width = w .Height = h End With Set p = Nothing End Sub
Att. Andre de Mattos Ferraz
- Sugerido como Resposta André de Mattos Ferraz segunda-feira, 27 de abril de 2015 12:56
- Marcado como Resposta Josiasweb segunda-feira, 27 de abril de 2015 20:41
Todas as Respostas
-
-
Natan vou tentar te explicar melhor o que eu gostaria.
Plan3 Cel A2= Digito o Cód. do Produto ex, (10027)
Plan3 Cel A12 = Carrega o endereço da Imagem do Produto ex.
(C:\Users\josias\Desktop\foto\10027. jpg)
Preciso carregar esta imagem nesta mesma planilha.
Não estou conseguindo com seu vb anterior.
Vc poderia refaze por favor. Obrigado!!
-
-
-
Tente isso:
Sub TestInsertPictureInRange() Dim objFSO As Object Set objFSO = CreateObject("Scripting.FileSystemObject") Dim objFolder As Object Dim objFile As Object Dim i As Integer i = 1 Set objFolder = objFSO.GetFolder("C:\Users\h162524\Desktop\") For Each objFile In objFolder.Files If InStrRev(objFile.Name, ".png") <> 0 Then InsertPictureInRange objFile.Path, Range("B" & i & ":C" & i) i = i + 1 End If Next objFile End Sub Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range) ' inserts a picture and resizes it to fit the TargetCells range Dim p As Object, t As Double, l As Double, w As Double, h As Double If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub If Dir(PictureFileName) = "" Then Exit Sub ' import picture Set p = ActiveSheet.Pictures.Insert(PictureFileName) ' determine positions With TargetCells t = .Top l = .Left w = .Offset(0, .Columns.Count).Left - .Left h = .Offset(.Rows.Count, 0).Top - .Top End With ' position picture With p .Top = t .Left = l .Width = w .Height = h End With Set p = Nothing End Sub
Att. Andre de Mattos Ferraz
- Sugerido como Resposta André de Mattos Ferraz segunda-feira, 27 de abril de 2015 12:56
- Marcado como Resposta Josiasweb segunda-feira, 27 de abril de 2015 20:41
-
-