Re: VBA Comment formatting

ROBERTO B FILHO

New Member
Joined
May 21, 2018
Messages
1
Re: VBA Comment formatting

[QUOTE = ed.ayers315; 2981660] Oi Worf,

Obrigado pela resposta e pelo código.

Eu precisei modificá-lo um pouco para obter a imagem do comentário para ajustar a altura da linha da célula ativa.

Obrigado e tenha um bom e feliz ano novo !!! [/QUOTE]
Code:
Sub INSERT_COMMENT_PICTURE () 
' 
' INSERT_COMMENT_PICTURE Macro 
Esmagar HasCom, Pict $, Ans%, p Como Objeto, t #, L #, w #, h # 
 
Definir HasCom = ActiveCell.Comment 
Se Não HasCom Não é Nada, então ActiveCell.Comment .Delete 
Set HasCom = Nada 
 
GetPict: 
Pict = Application.GetOpenFilename 
'Nota você pode carregar, quase qualquer formato de arquivo 
If Pict = "False" Then End
 
Ans = MsgBox ("Abrir:" & Pict, vbYesNo + vbExclamation, "Usar esta imagem?") 
 
Se Ans = vbNo Então GoTo GetPict 
Set p = Imagem flutuante temporária de ActiveSheet.Pictures.Insert (Pict) ' 
Com ActiveCell 
    t = .Top 
    L = .Left 
    w =. Offset (0, 1) .Left - .Left 
    L = L + w / 2 - p.Width / 2 
    Se L <1 Então, L = 1 
    h = .Offset (1, 0) .Top - .Top 
    t = t + h / 2 - p.Altura / 2 
    Se t <1 Então t = 1 
    .AddComment 
    .Comment.Visible = True 
 
        Com .Comment.Shape 
         .LockAspectRatio = msoTrue 
        .Height = ActiveCell.RowHeight - 10 'faça o tamanho do comentário, assim, o tamanho da imagem é menor que a altura da linha ativa
        .LockAspectRatio = msoTrue 
        .Fill.Transparency = 0 # 
        .Fill.UserPicture picturefile: = Pict. 
        Top = t 
        .Left = L 
       End Com 
Fim Com 
p.Delete 
Set p = Nada 
End Sub
 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Re: VBA Comment formatting

Olá Roberto

Você precisa de alguma ajuda?
 
Upvote 0

Forum statistics

Threads
1,213,532
Messages
6,114,177
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top