Condividi:        

CENTRARE IMMAGINE IN CELLA DI DIMENSIONI VARIABILI

Hai problemi con i file Zip, vuoi formattare l'HD, non sai come funziona FireFox? O magari ti serve proprio quel programmino di cui non ricordi il nome! Ecco il forum dove poter risolvere i tuoi problemi.

Moderatori: Dylan666, hydra, gahan

CENTRARE IMMAGINE IN CELLA DI DIMENSIONI VARIABILI

Postdi dario_79 » 14/03/14 08:13

Ciao ragazzi, ho un problema con una macro.
Praticamente questa macro inserisce nella colonna b del foglio1 le immagini relative al contenuto delle cellle della colnna a. Siccome l'altezza della cella in colonna a può essere variabile, mentre, le dimensioni delle immagini sono fisse, come posso modificare la parte finale della seguente macro per far sì che le immagini vengano caricate al centro delle celle in colonna b???
PREMESSA: non sono bravo con VBA e questa macro l'ho trovata in un forum

Sub InsImg()
Application.ScreenUpdating = False
ActiveSheet.Shapes.SelectAll
Selection.Delete
mPath = ActiveWorkbook.Path
r = 2 ' riga inizio prodotti
Lr = Range("A" & Rows.Count).End(xlUp).Row ' ultima riga da analizzare
For i = r To Lr
mFoto = Cells(i, 1)

If Len(mFoto & "") <> 0 Then ' se c'e' il nome prodotto
If Dir(mPath & "\" & mFoto & ".jpg") <> "" Then ' se la foto esiste
' inserisce foto e adatta a dimensioni cella/colonna B
With ActiveSheet.Pictures.Insert(mPath & "\" & mFoto & ".jpg

.Top = Range("B" & i).Top + 5
.Left = Range("B" & i).Left + 5
.Height = Range("B" & i).Height - 10
.Width = Range("B" & i).Width - 10
End With
End If
End If
Next i
Application.ScreenUpdating = True

End Sub

GRAZIE
dario_79
Newbie
 
Post: 6
Iscritto il: 13/03/14 23:56

Sponsor
 

Re: CENTRARE IMMAGINE IN CELLA DI DIMENSIONI VARIABILI

Postdi Dylan666 » 14/03/14 14:11

http://answers.microsoft.com/en-us/offi ... b599b31bf5
And here is a sub to insert and center a picture on a specific cell:

Codice: Seleziona tutto
Sub InsertCenterPicture()

Dim myR As Range
Set myR = Selection
'Insert the picture
ActiveSheet.Pictures.Insert( _
   Application.GetOpenFilename( _
   "JPG picture files (*.jpg),*.jpg", , "Select the picture")).Select
  'center the picture on the current range selection
Selection.ShapeRange.IncrementLeft (myR.Width - Selection.ShapeRange.Width) / 2

End Sub
Avatar utente
Dylan666
Moderatore
 
Post: 39993
Iscritto il: 18/11/03 16:46


Torna a Software Windows


Topic correlati a "CENTRARE IMMAGINE IN CELLA DI DIMENSIONI VARIABILI":


Chi c’è in linea

Visitano il forum: Nessuno e 92 ospiti